-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile-prod
53 lines (39 loc) · 1.55 KB
/
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
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
49
50
51
52
53
# Based on https://mherman.org/blog/dockerizing-an-angular-app/
# base image
FROM node:18-alpine as builder
# removed this for now
# install chrome for protractor tests
# RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
# RUN apt-get update && apt-get install -yq google-chrome-stable
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
RUN npm install -g @angular/[email protected]
# add app
COPY . /app
# Build the project and copy the files
RUN npm run ng build -- --deploy-url=/ --c production
FROM bitnami/nginx:latest
#!/bin/sh
COPY ./.nginx/nginx.conf /opt/bitnami/nginx/conf/server_blocks/frontend.conf
## Remove default nginx index page
# RUN rm -rf /app/*
# Copy from the stahg 1
COPY --from=builder /app/dist/OS2IoT-frontend /app
## Change user to perform privileged actions
USER 0
# Install envsubst
RUN apt-get update && apt-get install -y gettext-base
# Make sure we have write access to the env.js file without using the root user
RUN chown 1001 /app/assets/env.js
# Revert to the original non-root user
USER 1001
EXPOSE 8080
EXPOSE 8081
# Substiture placeholders in env.template.js using environment variables overwrite env.js
CMD ["/bin/sh", "-c", "envsubst < /app/assets/env.template.js > /app/assets/env.js && exec nginx -g 'daemon off;'"]