-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
46 lines (41 loc) · 1.26 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
46
# Client
FROM registry.access.redhat.com/ubi8/nodejs-18:1 AS client
# Build client
ENV HOME_CLIENT /opt/app-root/src/app/client
# Using root to transfer ownership of work dir
USER root
RUN mkdir -p ${HOME_CLIENT}
RUN chown -R 1008111001 ${HOME_CLIENT}
WORKDIR ${HOME_CLIENT}
COPY client/package*.json ./
RUN chown -R 1008040000 .
USER 1008040000
RUN npm set progress=false && npm ci --no-cache
COPY client/. .
RUN INLINE_RUNTIME_CHUNK=false npm run build
# Server
FROM registry.access.redhat.com/ubi8/nodejs-18:1 AS server
# Static env vars
ARG VERSION
ENV VERSION $VERSION
ENV NODE_ENV production
ENV HOME_SERVER /opt/app-root/src/app/server
ENV HOME_CLIENT /opt/app-root/src/app/client
# Configure server
# Using root to transfer ownership of work dir
USER root
RUN mkdir -p ${HOME_SERVER}
RUN mkdir -p ${HOME_CLIENT}
RUN chown -R 1001 ${HOME_CLIENT}
RUN chown -R 1001 ${HOME_SERVER}
COPY --from=client /opt/app-root/src/app/client/build /opt/app-root/src/app/client/build/.
WORKDIR ${HOME_SERVER}
COPY server/package*.json ./
RUN npm set progress=false && npm ci --no-cache
RUN chown -R 1001:0 "/opt/app-root/src/.npm"
RUN chgrp -R 0 "/opt/app-root/src/.npm" && chmod -R g=u "/opt/app-root/src/.npm"
USER 1001
COPY server/. .
# Run app
EXPOSE 8080
CMD [ "npm", "run", "start" ]