-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (31 loc) · 1.29 KB
/
Dockerfile
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
# Stage 1 - dependencies
FROM --platform=$BUILDPLATFORM node:20.2.0-alpine3.17 as build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install --silent
COPY . .
ARG STAGE=production
RUN npm run build -- --output-path=./dist/out --configuration $STAGE
RUN echo RELEASE_$(grep '"version":' package.json | cut -d\" -f4)_$(date -u +%Y-%m-%dT%H:%M:%SUTC)_$STAGE > ./dist/out/version
# Stage 3 - run
FROM nginx:1.27.0-alpine-slim as run
LABEL maintainer="[email protected]"
ENV REGISTRY_HOST=http://localhost:5000
ENV TOKEN_SECRET=PleaseReplaceMeAsSoonAsPossible
ENV CHECK_PULL_ACCESS=false
RUN apk update && apk add bash
COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist/out/ /usr/share/nginx/html
RUN chown -R nginx:nginx /usr/share/nginx \
&& chown -R nginx:nginx /var/cache/nginx \
&& chown -R nginx:nginx /var/log/nginx \
&& chown -R nginx:nginx /etc/nginx/conf.d \
&& touch /var/run/nginx.pid \
&& chown -R nginx:nginx /var/run/nginx.pid
WORKDIR /usr/share/nginx
USER nginx
RUN echo "mainFileName=\"\$(ls html/main*.js)\" \
&& envsubst '\${REGISTRY_HOST} \${TOKEN_SECRET} \${CHECK_PULL_ACCESS}' < \${mainFileName} > main.tmp \
&& mv main.tmp \${mainFileName} \
&& nginx -g 'daemon off;'" > run.sh
CMD [ "bash", "run.sh" ]