-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (29 loc) · 981 Bytes
/
Dockerfile
File metadata and controls
43 lines (29 loc) · 981 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
38
39
40
41
42
43
# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:18-alpine AS production
ENV NODE_ENV=production
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init \
&& rm -rf /var/cache/apk/*
WORKDIR /app
# Install production dependencies as root before switching user
COPY package.json package-lock.json ./
RUN npm ci --only=production --ignore-scripts \
&& npm cache clean --force
COPY --from=builder /app/dist ./dist
# Create writable tmp dir for the app, then lock down ownership
RUN mkdir -p /app/tmp && chown -R node:node /app
# Drop to non-root user
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
# dumb-init ensures SIGTERM is forwarded to the Node process
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "dist/main.js"]