Skip to content

Instantly share code, notes, and snippets.

@kanthvallampati
Last active September 6, 2022 04:27
Show Gist options
  • Save kanthvallampati/d6b83be5d1f070e866e7517a2bfe0467 to your computer and use it in GitHub Desktop.
Save kanthvallampati/d6b83be5d1f070e866e7517a2bfe0467 to your computer and use it in GitHub Desktop.
Sample Dockerfile to build and deploy an Angular app in Kubernetes
### STAGE 1: Build ###
FROM node:14.19.3 AS build
# Create app directory
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install app dependencies
RUN npm install --force --verbose
# Bundle app source
COPY . .
# Build prod
RUN $(npm bin)/ng build --prod
### STAGE 2: Run ###
# Prepare production environment
FROM nginx:latest
# Copy dist
COPY --from=build /usr/src/app/<dist-folder>/<app-name> /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment