-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (29 loc) · 1.28 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (29 loc) · 1.28 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
# === Build stage: Install dependencies and dumb-init ===
FROM dhi.io/node:26.8.1-alpine3.24-dev@sha256:22f9b40622a726cf95195d5543460aa387c228a78e3788d9d54c0dc1f6933f12 AS builder
WORKDIR /usr/src/app
# Install dumb-init for process management
RUN apk add --no-cache dumb-init
# Install Dependencies
COPY package.json package-lock.json* ./
RUN npm ci
# Copy App Code
COPY . .
RUN npm run build
RUN mv views/app.min.js views/app.js && rm views/input.css
RUN npm prune --production && npm cache clean --force
# === Final stage: Create minimal runtime image ===
FROM dhi.io/node:26.8.1-alpine3.24@sha256:b2fa395462a05d081398db7f49adada41d48aaa9e6576148aecc065744c583d9
ENV NODE_ENV=production
ENV PATH=/app/node_modules/.bin:$PATH
# Copy dumb-init from builder
COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init
# Copy application with dependencies from builder
COPY --from=builder --chown=node:node /usr/src/app /app
WORKDIR /app
# Expose Port 4040 (IP Echo Service)
EXPOSE 4040
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD ["node", "-e", "fetch('http://127.0.0.1:4040/health').then(res => process.exit(res.ok ? 0 : 1)).catch(() => process.exit(1))"]
# Start with dumb-init for proper signal handling
CMD ["dumb-init", "node", "server.js"]