-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.CSR
48 lines (38 loc) · 1.36 KB
/
Dockerfile.CSR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Stage 1: Compile and Build angular codebase
# Use official node image as the base image
FROM node:16 as build
# Set the working directory
WORKDIR /usr/local/app
# Add the source code to app
COPY src/ /usr/local/app/src
COPY package.json /usr/local/app
COPY tsconfig.app.json /usr/local/app
COPY tsconfig.json /usr/local/app
COPY angular.json /usr/local/app
COPY default.conf /usr/local/app
COPY karma.conf.js /usr/local/app
COPY package-lock.json /usr/local/app
COPY tsconfig.spec.json /usr/local/app
# COPY nginx.conf /usr/local/app
# Install all the dependencies
RUN npm install
# Generate the build of the application
RUN npm run build
# Stage 2: Serve app with nginx server
# Use official nginx image as the base image
FROM nginxinc/nginx-unprivileged:latest
# USER 0
# Use root user to copy dist folder and modify user access to specific folder
USER root
# RUN apt-get install --no-cache gettext
# Copy application and custom NGINX configuration
# Copy the build output to replace the default nginx contents.
COPY --from=build /usr/local/app/dist/onbowman-13 /usr/share/nginx/html
COPY --from=build /usr/local/app/default.conf /etc/nginx/conf.d/default.conf
# Setup unprivileged user 1001
RUN chown -R 1001 /usr/share/nginx/html
# Use user 1001
USER 1001
# Expose a port that is higher than 1024 due to unprivileged access
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]