-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.72 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (44 loc) · 1.72 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
FROM node:26-slim AS builder
# Install build dependencies for native modules (sqlite3, ldapts) and git for version tagging
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 make g++ git && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install ALL dependencies (including devDependencies for build)
COPY package*.json ./
RUN npm config set allow-scripts true && \
npm ci
# Copy source and build
COPY . .
RUN npm run build
# Production dependencies stage - use debian-slim for native module compilation
FROM node:26-slim AS prod-deps
# Install build dependencies for native modules (sqlite3, ldapts)
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 make g++ && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package*.json ./
RUN npm config set allow-scripts true && \
npm ci --omit=dev && \
npm cache clean --force && \
rm -rf /root/.npm
# Production stage - use the same debian-slim base so native modules remain compatible
FROM node:26-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV NODE_ENV=production HOST=0.0.0.0 PORT=9093
# Create non-root user
RUN groupadd -g 1001 nodejs && \
useradd -u 1001 -g nodejs -s /bin/false nodejs
# Copy built app from builder, production deps from prod-deps stage
COPY --chown=1001:1001 --from=builder /app/build ./build
COPY --chown=1001:1001 --from=prod-deps /app/node_modules ./node_modules
COPY --chown=1001:1001 --from=builder /app/package.json ./
USER nodejs
EXPOSE 9093
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:9093/auth-admin/health || exit 1
CMD ["node", "build"]