Skip to content

Instantly share code, notes, and snippets.

@sandeep540
Created June 14, 2019 19:32
Show Gist options
  • Save sandeep540/a50abc3f316efbcc7251ac05da3ddc48 to your computer and use it in GitHub Desktop.
Save sandeep540/a50abc3f316efbcc7251ac05da3ddc48 to your computer and use it in GitHub Desktop.
Angular Dockerfile with multistage
# Multi-step Docker File Builder
# STEP 1 : Choosing the Base of our image
FROM node:alpine as builder
ARG env=prod
#Adding label for tagging purpose
LABEL maintainer="kn.sandeep@gmail.com"
#STEP 2: Updating APK for updating Alpine Docker Image
RUN apk update && apk add --no-cache make git
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build:${env}
# STEP 2 build a small nginx image with static website
FROM nginx:alpine
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## */
## From 'builder' copy website to default nginx public folder
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
## docker build -t sandeep540/flex-angular-app .
## docker push sandeep540/flex-angular-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment