-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
77 lines (50 loc) · 1.8 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Stage 0 - base node customizations
FROM node:20.18.0-alpine3.19 AS base-node
RUN npm install -g npm@10.9.0
# Stage 1 - api build - requires development environment because typescript
FROM base-node AS api-build-stage
ENV NODE_ENV=development
WORKDIR /usr/src/api
COPY api/package*.json ./
COPY api/tsconfig*.json ./
RUN npm install
COPY api ./
RUN npm run build
# Copy html files, remove once we are using Vite for build process
COPY api/src/templates ./dist/templates
# Stage 2 - web build - requires development environment to install vue-cli-service
FROM base-node AS web-build-stage
ENV NODE_ENV=development
WORKDIR /usr/src/web
COPY web/package*.json ./
COPY web/tsconfig*.json ./
COPY web/vite.config.js ./
RUN npm install
COPY web ./
# Switching to production mode for build environment.
ENV NODE_ENV=production
RUN npm run build
# Stage 3 - production setup
FROM base-node
ARG RELEASE_TAG
ARG GIT_COMMIT_HASH
ENV RELEASE_TAG=${RELEASE_TAG}
ENV GIT_COMMIT_HASH=${GIT_COMMIT_HASH}
# Persists TZ=UTC effect after container build and into container run
# Ensures dates/times are consistently formated as UTC
# Conversion to local time should happen in the UI
ENV TZ=UTC
ENV NODE_ENV=production
USER node
WORKDIR /home/node/app
RUN chown -R node:node /home/node/app
COPY --from=api-build-stage --chown=node:node /usr/src/api/package*.json ./
RUN npm install && npm cache clean --force --loglevel=error
COPY --from=api-build-stage --chown=node:node /usr/src/api/dist ./dist/
COPY --from=web-build-stage --chown=node:node /usr/src/web/dist ./dist/web/
RUN echo "RELEASE_TAG=${RELEASE_TAG}" >> VERSION
RUN echo "GIT_COMMIT_HASH=${GIT_COMMIT_HASH}" >> VERSION
EXPOSE 3000
COPY --from=api-build-stage --chown=node:node /usr/src/api/bin/boot-app.sh ./bin/
RUN chmod +x ./bin/boot-app.sh
CMD ["./bin/boot-app.sh"]