-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathDockerfile
50 lines (34 loc) · 1.76 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
47
48
49
50
FROM node:16.17.1-alpine3.15 as base
# Ensuring that all npm packages and commands are executed with a non-root user
USER node
ENV APP_PATH=/home/node/app
ENV APP_BACKEND_PATH=${APP_PATH}/teammapper-backend
ENV APP_FRONTEND_PATH=${APP_PATH}/teammapper-frontend
RUN mkdir -p $APP_PATH
WORKDIR $APP_PATH
FROM base as production_buildstage
USER node
COPY --chown=node:node teammapper-backend/package.json teammapper-backend/package-lock.json $APP_BACKEND_PATH/
RUN npm --prefix teammapper-backend ci
COPY --chown=node:node teammapper-frontend/package.json teammapper-frontend/package-lock.json $APP_FRONTEND_PATH/
RUN npm --prefix teammapper-frontend ci
COPY --chown=node:node package.json $APP_PATH/
COPY --chown=node:node teammapper-backend $APP_BACKEND_PATH/
RUN npm run build:backend:prod
COPY --chown=node:node teammapper-frontend $APP_FRONTEND_PATH/
RUN GENERATE_SOURCEMAP=false npm run build:frontend:prod
FROM base as production
USER node
COPY --chown=node:node package.json $APP_PATH/
COPY --chown=node:node teammapper-backend/package.json teammapper-backend/package-lock.json $APP_BACKEND_PATH/
RUN npm --prefix teammapper-backend install --production
COPY --chown=node:node --from=production_buildstage $APP_BACKEND_PATH/dist $APP_BACKEND_PATH/dist
COPY --chown=node:node --from=production_buildstage $APP_FRONTEND_PATH/dist $APP_BACKEND_PATH/client
COPY --chown=node:node entrypoint.prod.sh $APP_PATH/
CMD ["./entrypoint.prod.sh"]
FROM base as development
USER node
COPY --chown=node:node teammapper-frontend/package.json teammapper-frontend/package-lock.json $APP_FRONTEND_PATH/
RUN npm --prefix teammapper-frontend install
COPY --chown=node:node teammapper-backend/package.json teammapper-backend/package-lock.json $APP_BACKEND_PATH/
RUN npm --prefix teammapper-backend install