forked from IOCOTech/Angular-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile.prod
23 lines (23 loc) · 984 Bytes
/
dockerfile.prod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
FROM tiangolo/node-frontend:10 as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
# Install specific angular version, if the app updates this must be updated as well
RUN npm install -g @angular/cli@11.0.5
COPY ./ /app/
# Run unit tests
RUN ng test --browsers ChromeHeadlessNoSandbox --watch=false
# Configuration can be read from environmental variables setup on the CI/CD server
ARG configuration=production
# Build the angular application
RUN ng build --output-path=./dist/out --configuration $configuration
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.19.6-alpine
COPY --from=build-stage /app/dist/out/ /usr/share/nginx/html
# Copy the default nginx.conf provided by tiangolo/node-frontend
COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf
# expose port
EXPOSE 80
# run nginx
CMD ["nginx", "-g", "daemon off;"]