diff --git a/Dockerfile-arm b/Dockerfile-arm new file mode 100644 index 00000000..95e30aa1 --- /dev/null +++ b/Dockerfile-arm @@ -0,0 +1,30 @@ +# Usage: +# +# Build image: +# docker build -t jojozhuang/text-compare-angular-arm . -f Dockerfile-ARM +# +# Run image (on localhost:12010): +# docker run -d --name text-compare -p 12010:80 jojozhuang/text-compare-angular-arm +# +# Run image as virtual host (read more: https://github.com/nginx-proxy/nginx-proxy): +# docker run -e VIRTUAL_HOST=text-compare.your-domain.com --name text-compare jojozhuang/text-compare-angular + +# Stage 1, based on Node.js, to build and compile Angular + +FROM node:16.10.0-alpine as builder + +WORKDIR /ng-app + +COPY package*.json tsconfig*.json angular.json ./ +COPY ./src ./src + +RUN npm ci --quiet && npm run build-nas + +# Stage 2, based on Nginx, to have only the compiled app, ready for production with Nginx + +FROM arm64v8/nginx + +COPY ./nginx.conf /etc/nginx/conf.d/default.conf + +## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder +COPY --from=builder /ng-app/dist /usr/share/nginx/html \ No newline at end of file diff --git a/k8s/text-compare-arm.yaml b/k8s/text-compare-arm.yaml new file mode 100644 index 00000000..779563d9 --- /dev/null +++ b/k8s/text-compare-arm.yaml @@ -0,0 +1,44 @@ +# Setup loocally +# 1. Build image for ARM platform +# docker build -t text-compare-angular . -f Dockerfile-ARM +# 2. Deploy to k8s: +# kubectl apply -f k8s/text-compare.yaml +# 3. Create service in minikube: +# minikube service text-compare-service +# 4. Access the url from step 3. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: text-compare-deployment + labels: + app: text-compare +spec: + replicas: 1 + selector: + matchLabels: + app: text-compare + template: + metadata: + labels: + app: text-compare + spec: + containers: + - name: text-compare + image: jojozhuang/text-compare-angular + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: text-compare-service +spec: + selector: + app: text-compare + type: LoadBalancer # assign an external IP address to accept external request + ports: + - protocol: TCP + port: 12011 + targetPort: 80 + nodePort: 31000 # must be between 30000 and 32767 \ No newline at end of file