-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.29 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (38 loc) · 1.29 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
# Express 5 + PostgreSQL + OpenTelemetry Example
# Multi-stage Dockerfile | Dec 2025
# ==========================================================================
# Stage 1: Builder
# ==========================================================================
FROM node:24-alpine AS builder
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm ci
# Copy source and build
COPY tsconfig.json ./
COPY drizzle.config.ts ./
COPY src ./src
RUN npm run build
# ==========================================================================
# Stage 2: Runtime
# ==========================================================================
FROM node:24-alpine AS runtime
WORKDIR /app
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -S appuser -u 1001 -G appgroup
# Install production dependencies only
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy built application
COPY --from=builder /app/dist ./dist
# Copy drizzle migrations from build context
COPY drizzle ./drizzle
# Set ownership
RUN chown -R appuser:appgroup /app
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8000/api/health || exit 1
EXPOSE 8000
CMD ["node", "dist/index.js"]