-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker
More file actions
65 lines (46 loc) · 1.83 KB
/
Dockerfile.worker
File metadata and controls
65 lines (46 loc) · 1.83 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
61
62
63
64
65
# Multi-stage Dockerfile for Temporal Worker Service
# Optimized for production deployment in Kubernetes
# Stage 1: Base image with dependencies
FROM node:24.12.0-alpine AS base
LABEL maintainer="Darshit Vora"
LABEL description="Temporal Worker Service for workflow execution"
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Set working directory
WORKDIR /usr/src/app
# Copy package files
COPY package*.json ./
# Stage 2: Development dependencies
FROM base AS development
ENV NODE_ENV=development
# Install all dependencies (including devDependencies)
RUN npm ci --include=dev
# Copy source code
COPY . .
# Use dumb-init to handle signals properly
CMD ["dumb-init", "npm", "run", "start:worker:all"]
# Stage 3: Production dependencies
FROM base AS production-deps
ENV NODE_ENV=production
# Install only production dependencies
RUN npm ci --omit=dev && npm cache clean --force
# Stage 4: Production build
FROM base AS production
ENV NODE_ENV=production
# Copy production dependencies from production-deps stage
COPY --from=production-deps /usr/src/app/node_modules ./node_modules
# Copy application source (workers need access to activities and workflows)
COPY . .
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /usr/src/app
# Create logs directory with proper permissions
RUN mkdir -p logs && chown -R nodejs:nodejs logs
# Switch to non-root user
USER nodejs
# Workers don't expose HTTP ports - they connect to Temporal Server via gRPC
# No health check needed - Temporal Server monitors worker health via heartbeat
# Use dumb-init to handle signals properly (important for graceful worker shutdown)
# Workers need clean shutdown to complete in-flight activities
CMD ["dumb-init", "node", "./src/temporal/workers/user.worker.js"]