-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (56 loc) · 1.96 KB
/
Copy pathDockerfile
File metadata and controls
81 lines (56 loc) · 1.96 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
# Multi-stage build for DNSMgr (Frontend + Backend in one image)
FROM node:24-alpine AS builder
# Accept CI build flag
ARG CI_BUILD=false
# Install pnpm
RUN npm install -g pnpm
# Set working directory
WORKDIR /app
# Copy root package files
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
# Copy server package files
COPY server/package.json server/.npmrc ./server/
# Copy client package files
COPY client/package.json ./client/
# Install all dependencies (including devDependencies for build)
RUN pnpm install --no-frozen-lockfile
# Copy source code
COPY . .
# Build client (frontend)
RUN pnpm --filter dnsmgr-client build
# Build server (backend)
RUN pnpm --filter dnsmgr-server build
# Production stage
FROM node:24-alpine AS production
# Accept CI build flag from builder
ARG CI_BUILD=false
# Install pnpm and database client tools for DSM backups
RUN npm install -g pnpm && \
apk add --no-cache mysql-client postgresql-client sqlite
# Create app directory
WORKDIR /app
# Copy root package files
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
# Copy server package files
COPY server/package.json server/.npmrc ./server/
# Install production dependencies only
RUN pnpm install --no-frozen-lockfile --prod
# Copy built server files from builder
COPY --from=builder /app/server/dist ./server/dist
# Copy server scripts
COPY --from=builder /app/server/scripts ./server/scripts
# Copy built client files from builder
COPY --from=builder /app/client/dist ./client/dist
# Create data directory for persistent storage
RUN mkdir -p /app/data
# Expose port
EXPOSE 3001
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3001
ENV CI_BUILD=${CI_BUILD}
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/api/init/status', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start the server (which also serves the frontend)
CMD ["node", "server/dist/app.js"]