-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (26 loc) · 993 Bytes
/
Dockerfile
File metadata and controls
37 lines (26 loc) · 993 Bytes
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
# Multi-stage build for production
FROM node:25.2.1-alpine AS builder
# Install build dependencies needed for native modules (better-sqlite3)
RUN apk add --no-cache python3 make g++
WORKDIR /app
# Copy package files for dependency installation
COPY package.json package-lock.json ./
# Skip lifecycle scripts (like husky prepare) but then rebuild better-sqlite3 native bindings
RUN npm ci --omit=dev --omit=optional --ignore-scripts && \
npm rebuild better-sqlite3 && \
npm cache clean --force
# Production stage
FROM node:25.2.1-alpine
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 -G nodejs
WORKDIR /app
# Copy dependencies from builder (includes compiled native modules)
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
# Copy application code
COPY --chown=nodejs:nodejs package.json ./
COPY --chown=nodejs:nodejs src ./src
# Switch to non-root user
USER nodejs
EXPOSE 3000
CMD ["node", "src/server.js"]