-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (72 loc) 路 2.52 KB
/
Copy pathDockerfile
File metadata and controls
88 lines (72 loc) 路 2.52 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
87
88
# Stage 1: Base image with build dependencies
FROM node:20-slim AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Install server dependencies
FROM base AS server-deps
WORKDIR /app/server
COPY server/package*.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --prefer-offline --no-audit 2>/dev/null || npm install
# Stage 3: Build server
FROM server-deps AS server-build
COPY server ./
RUN npm run build
# Stage 4: Install UI dependencies (parallel with server)
FROM base AS ui-deps
WORKDIR /app/ui
COPY ui/package.json ./
# Don't use package-lock for UI - native Tailwind modules need platform-specific install
RUN --mount=type=cache,target=/root/.npm \
npm install --no-audit --prefer-offline
# Stage 5: Build UI
FROM ui-deps AS ui-build
WORKDIR /app/ui
# Copy config files first (change less frequently than source)
COPY ui/nuxt.config.ts ui/tsconfig.json ui/tailwind.config.* ui/app.config.* ./
# Copy remaining source
COPY ui ./
ENV NODE_ENV=production
RUN npx nuxt prepare && npm run build
# Stage 6: Production runtime image
FROM node:20-slim AS runtime
# Install only runtime dependencies (supervisor)
RUN apt-get update && \
apt-get install -y --no-install-recommends supervisor && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /var/log/supervisor
WORKDIR /app
# Copy server production dependencies and built code
COPY --from=server-deps /app/server/node_modules ./server/node_modules
COPY --from=server-build /app/server/dist ./server/dist
COPY --from=server-build /app/server/package*.json ./server/
# Copy UI production dependencies and built code
COPY --from=ui-deps /app/ui/node_modules ./ui/node_modules
COPY --from=ui-build /app/ui/.output ./ui/.output
COPY --from=ui-build /app/ui/package*.json ./ui/
# Copy supervisord configuration
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create data and logs directories with proper permissions
RUN mkdir -p /app/data /app/logs /var/run && \
chown -R node:node /app/data /app/logs /app && \
chown node:node /var/run
# Expose ports (configurable via SERVER_PORT and UI_PORT env vars)
EXPOSE 3847 5847
# Set environment variables
ENV DB_PATH=/app/data
ENV SERVER_PORT=5847
ENV UI_PORT=3847
ENV HOST=0.0.0.0
ENV NODE_ENV=production
ENV LOG_LEVEL=info
ENV UI_ORIGIN=http://localhost:3847
# Define volumes for persistence
VOLUME ["/app/data", "/app/logs"]
# Switch to non-root user
USER node
# Start supervisor
CMD ["/usr/bin/supervisord", "-n"]