forked from Tampere/vuorovaikutusalusta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (63 loc) · 1.6 KB
/
Dockerfile
File metadata and controls
86 lines (63 loc) · 1.6 KB
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
##
# Production Dockerfile
##
###
# Base image declaration
###
FROM node:22.14-alpine AS base
ENV APPDIR=/app
###
# Client build stage
###
FROM base AS client-build
WORKDIR ${APPDIR}/client
COPY client/package*.json ./
RUN npm ci
COPY interfaces ../interfaces
COPY client ./
# Build argument for the app version (to be injected into the application)
ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}
# Build argument for feature flags
ARG VITE_ENABLED_FEATURES='[]'
ENV VITE_ENABLED_FEATURES=${VITE_ENABLED_FEATURES}
RUN npm run build
###
# Server build stage
###
FROM base AS server-build
WORKDIR ${APPDIR}/server
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
COPY server/package*.json ./
RUN npm ci
COPY interfaces ../interfaces
COPY server ./
RUN npm run build
RUN rm -r src
###
# Main image build
###
FROM base AS main
# Install all dependencies (GDAL & others for Puppeteer)
RUN apk update && apk add \
gdal-tools \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
font-noto-emoji
# Add non-root user with explicit UID and GID
RUN addgroup --system --gid 1001 appGroup && \
adduser --system --uid 1001 appUser
WORKDIR ${APPDIR}
COPY --chown=appUser:appGroup --from=server-build ${APPDIR}/server ./
COPY --chown=appUser:appGroup --from=client-build ${APPDIR}/client/dist ./static/
ENV TZ=Europe/Helsinki
# Define Chromium path, as it was not installed in the previous phase
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Don't run the app as root
USER appUser
CMD ["npm", "start"]