-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (63 loc) · 2.68 KB
/
Copy pathDockerfile
File metadata and controls
84 lines (63 loc) · 2.68 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# ============================================================================
# Multi-Agent Platform - Production Dockerfile
# ============================================================================
# Multi-stage build for optimal image size and security
#
# Build: docker build -t multi-agents-backend .
# Run: docker-compose -f docker-compose.prod.yml up -d
# ============================================================================
# ============================================================================
# Stage 1: Build
# ============================================================================
FROM node:20-alpine AS builder
WORKDIR /app
# Install build dependencies (needed for bcrypt native module)
RUN apk add --no-cache python3 make g++ git
# Copy package files first for better caching
COPY package*.json ./
# Install ALL dependencies (including devDependencies for build)
RUN npm ci
# Copy source code
COPY . .
# Build TypeScript
RUN npm run build
# Prune devDependencies for production
RUN npm prune --production
# ============================================================================
# Stage 2: Production Runtime
# ============================================================================
FROM node:20-alpine AS production
# Labels for image metadata
LABEL org.opencontainers.image.title="Multi-Agent Platform Backend"
LABEL org.opencontainers.image.description="Autonomous software development with Claude Agent SDK"
LABEL org.opencontainers.image.version="2.0.0"
WORKDIR /app
# Install runtime dependencies only
# - git: Required for agent git operations
# - openssh-client: For git SSH operations (optional)
RUN apk add --no-cache git openssh-client
# Create non-root user for security
RUN addgroup -g 1001 -S agents && \
adduser -S -D -H -u 1001 -h /app -s /sbin/nologin -G agents agents
# Copy built artifacts from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
# Copy any additional required files
COPY --from=builder /app/CLAUDE.md ./CLAUDE.md
# Create workspace directory with correct permissions
RUN mkdir -p /mnt/data/agent-workspace && \
chown -R agents:agents /mnt/data/agent-workspace
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3001
ENV AGENT_WORKSPACE_DIR=/mnt/data/agent-workspace
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
# Switch to non-root user
USER agents
# Start application
CMD ["node", "dist/index.js"]