Last active
August 19, 2021 11:51
-
-
Save sefatanam/cf50a3a60f5352521668c21c12741574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:alpine as builder | |
WORKDIR /app | |
COPY package.json package-lock.json ./ | |
ENV CI=1 | |
RUN npm ci | |
COPY . . | |
RUN npm run build -- --prod --output-path=/dist | |
# Deploy our Angular app to NGINX | |
FROM nginx:alpine | |
## Replace the default nginx index page with our Angular app | |
RUN rm -rf /usr/share/nginx/html/* | |
COPY --from=builder /dist /usr/share/nginx/html | |
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf | |
COPY ./nginx/gzip.conf /etc/nginx/gzip.conf | |
ENTRYPOINT ["nginx", "-g", "daemon off;"] |
get docker image as .tar => docker save -o D:\Practice\.....\....\....\...\app\docker.tar imageName
generate package-lock.json => npm install --package-lock
Angular v12 Update
# STEP 1 : build-stage
FROM node:14.16.0-alpine3.13 as build-stage
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
RUN npm run build
# STEP 2 : Production
FROM nginx:1.12-alpine
# RUN addgroup app && adduser -S -G app app
# USER app
COPY --from=build-stage /app/dist/APP_NAME /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT [ "nginx","-g","daemon off;" ]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1. Make a folder named 'nginx' root of your directory
2. Make a file named 'Dockerfile' at your root directory & paste the code bellow
Last but not the list make a file named '.dockerignore' also in your root directory & paste the code bellow
Folder Structure might be like this
Must have to 'package-lock.json' in your project.
Docker Command :
More about to run angular app in docker