-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (32 loc) · 1.32 KB
/
Dockerfile
File metadata and controls
47 lines (32 loc) · 1.32 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
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
# Install only production dependencies
RUN npm ci --omit=dev
# ─── Production Image ─────────────────────────────────────────
FROM node:20-alpine AS production
# Security: create a non-root user to run the application
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Install wget for healthcheck
RUN apk add --no-cache wget
WORKDIR /app
# Copy package.json first — needed so Node knows this is an ESM package ("type": "module")
COPY package*.json ./
# Copy production dependencies from builder stage
COPY --from=builder /app/node_modules ./node_modules
# Copy application source (everything except what's in .dockerignore)
COPY src ./src
COPY server.js ./
COPY worker.js ./
COPY config ./config
COPY templates ./templates
# Set ownership to non-root user
RUN chown -R appuser:appgroup /app
# Switch to non-root user
USER appuser
# FIXED: was 3000, must match PORT=3100 in .env and docker-compose.yml
EXPOSE 3100
# Health check — used by Docker and orchestrators (Kubernetes, ECS, Render)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3100/health || exit 1
CMD ["node", "server.js"]