forked from stratum-mining/sv2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (42 loc) · 1.47 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (42 loc) · 1.47 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
# Build stage - Full project (frontend + backend)
FROM node:24-alpine AS builder
WORKDIR /app
# Copy workspace package manifests so dependency installs are cached correctly
COPY package.json package-lock.json ./
COPY server/package.json server/
COPY shared/package.json shared/
# Install all dependencies
RUN npm ci
# Copy source
COPY . .
# Build frontend
RUN npm run build
# Build backend
WORKDIR /app/server
RUN npm run build
# Production stage
FROM node:24-alpine
WORKDIR /app
# Copy built frontend to public/
COPY --from=builder /app/dist ./public
# Copy built backend
COPY --from=builder /app/server/dist ./dist
COPY --from=builder /app/server/package.json ./server/
COPY --from=builder /app/package.json /app/package-lock.json ./
# Copy shared source (Node 24 loads .ts natively)
COPY --from=builder /app/shared ./shared
# Install server production deps using workspace resolution
# so @sv2-ui/shared resolves locally instead of from the registry
RUN npm install --omit=dev -w server && rm -f package.json package-lock.json
# Create a symlink so @sv2-ui/shared resolves at runtime
RUN mkdir -p /app/node_modules/@sv2-ui && ln -s ../../shared /app/node_modules/@sv2-ui/shared
# Create data directory for configs
RUN mkdir -p /app/data/config
ENV NODE_ENV=production
ENV PORT=8080
ENV CONFIG_DIR=/app/data/config
# tini ensures proper signal handling (Ctrl+C works)
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
EXPOSE 8080
CMD ["node", "--import", "tsx", "dist/index.js"]