-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (50 loc) · 1.58 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
# Stage 1: Builder
FROM node:22-alpine as builder
# Install brotli
RUN apk add --no-cache brotli
# Set working directory
WORKDIR /opt/vaalimasiina
# Copy necessary files for npm install
COPY .eslint* package.json package-lock.json /opt/vaalimasiina/
# Copy tsconfig files
COPY tsconfig.json tsconfig.node.json /opt/vaalimasiina/
# Copy vite configuration
COPY vite.config.ts /opt/vaalimasiina/
# Copy frontend source code
COPY src/frontend /opt/vaalimasiina/src/frontend
# Copy index.html
COPY index.html /opt/vaalimasiina/
# Copy public directory
COPY public /opt/vaalimasiina/public
# Copy environment variables for the frontend
COPY .env /opt/vaalimasiina/
# Set npm cache
RUN npm set cache .npm
# Install dependencies
RUN npm ci
# Set environment variable
ENV NODE_ENV=production
# Build the frontend
RUN npm run build
# Compress files with gzip and brotli
RUN find dist -type f \
-regex ".*\.\(js\|json\|html\|map\|css\|svg\|ico\|txt\)" -exec gzip -k "{}" \; -exec brotli "{}" \;
# Stage 2: Final Image
FROM node:22-alpine
# Set environment variables
ENV NODE_ENV=production
ENV HOST=0.0.0.0
# Set working directory
WORKDIR /opt/vaalimasiina
# Copy necessary files for npm install
COPY package.json package-lock.json /opt/vaalimasiina/
# Copy backend source code
COPY src/backend /opt/vaalimasiina/src/backend
# Set npm cache
RUN npm set cache .npm
# Install dependencies
RUN npm ci --production --ignore-scripts
# Copy the built frontend from the builder stage
COPY --from=builder /opt/vaalimasiina/dist /opt/vaalimasiina/dist
# Command to run the application
CMD ["npm", "run", "start"]