-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
88 lines (62 loc) · 1.56 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
78
79
80
81
82
83
84
85
86
87
88
##
# Production Dockerfile
##
###
# Base image declaration
###
FROM node:18.20.4-alpine AS base
ENV APPDIR /app
WORKDIR ${APPDIR}/shared
COPY shared/package*.json ./
RUN npm ci
COPY shared ./
RUN npm run build
# Install backend dependencies for tRPC client
WORKDIR ${APPDIR}/backend
COPY backend/package*.json ./
RUN npm ci
###
# Frontend build stage
###
FROM base AS frontend-build
WORKDIR ${APPDIR}/frontend
COPY frontend/package*.json ./
COPY frontend/patches ./patches
RUN npm ci
COPY frontend ./
COPY backend ../backend
# Build argument for the app version (to be injected into the application)
ARG APP_VERSION
ENV APP_VERSION ${APP_VERSION}
ARG VITE_FEATURE_SAP_REPORTS
ENV VITE_FEATURE_SAP_REPORTS ${VITE_FEATURE_SAP_REPORTS}
RUN npm run build
###
# Backend build stage
###
FROM base AS backend-build
WORKDIR ${APPDIR}/backend
COPY backend ./
RUN npm run build
# Remove src directory so the "@src" path always falls back to dist/ directory
RUN rm -rf src
###
# Main image build
###
FROM base AS main
WORKDIR ${APPDIR}/backend
# Remove the shared src folder to fix the runtime "@shared" path
RUN rm -rf ../shared/src
COPY --from=backend-build ${APPDIR}/backend ./
COPY --from=frontend-build ${APPDIR}/frontend/dist ./static/
ENV TZ=Europe/Helsinki
# Get extra hosts from build arguments and inject to environment for runtime access
ARG EXTRA_HOSTS
ENV EXTRA_HOSTS ${EXTRA_HOSTS}
CMD \
# Append extra host definitions if given
echo "${EXTRA_HOSTS}" >> /etc/hosts && \
# Execute DB migrations
npm run db-migrate:prod && \
# Start the application
npm start