-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
36 lines (26 loc) · 1.01 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
# TODO update to newer version: Active LTS or Current
FROM node:14 as dev
# cache hack (very fragile): initially only copy list of project dependencies
COPY --chown=node:node package.json package-lock.json /opt/node/
# install node dependencies to parent directory of code
WORKDIR /opt/node
USER node
RUN npm install
# add node modules binary folder to system PATH
ENV PATH=/opt/node/node_modules/.bin/:$PATH
# copy source code, switch to code directory
COPY --chown=node:node . /opt/node/app
WORKDIR /opt/node/app
EXPOSE 3000
CMD ["npm", "start"]
FROM dev as node-prod
ENV NODE_ENV=production
RUN npm run build
FROM nginx as prod
ARG REACT_APP_VERSION_STRING
ENV REACT_APP_VERSION_STRING=$REACT_APP_VERSION_STRING
COPY docker-entrypoint-override.sh /usr/bin/docker-entrypoint-override.sh
# write environment variables to config file and start
ENTRYPOINT ["/usr/bin/docker-entrypoint-override.sh", "/docker-entrypoint.sh"]
CMD ["nginx","-g","daemon off;"]
COPY --from=node-prod /opt/node/app/build /usr/share/nginx/html