-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (46 loc) · 1.97 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (46 loc) · 1.97 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
# Multi-stage build for Agent SDK API Server
# BEGINNER NOTE: Multi-stage builds keep the final image small by separating build and runtime
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
# Copy and display version for verification
COPY VERSION ./
RUN echo "=== BUILDING COMMIT ===" && cat VERSION && echo "====================="
# Copy package files
COPY package*.json ./
# Debug: Check what files we have
RUN echo "=== Files in /app ===" && ls -la && \
echo "=== Node version ===" && node --version && \
echo "=== NPM version ===" && npm --version && \
echo "=== Checking package files ===" && \
(test -f package.json && echo "✓ package.json exists" || echo "✗ package.json MISSING") && \
(test -f package-lock.json && echo "✓ package-lock.json exists" || echo "✗ package-lock.json MISSING")
# Install dependencies (including devDependencies for building)
RUN npm ci --verbose
# Copy source code and config
COPY tsconfig.json tsconfig.build.json ./
COPY src ./src
# Build TypeScript to JavaScript
RUN npm run build
# Stage 2: Runtime
FROM node:20-alpine AS runtime
WORKDIR /app
# Install Python3 for code execution tool
# BEGINNER NOTE: Required for CodeExecutionTool to run Python code
RUN apk add --no-cache python3 py3-pip
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --omit=dev
# Copy built JavaScript from builder stage
COPY --from=builder /app/dist ./dist
# Create workspace directory for FileSystemTool and code execution
# BEGINNER NOTE: This is where the agent can read/write files and run code safely
RUN mkdir -p /app/workspace && chmod 755 /app/workspace
# Expose port (default 3000, can be overridden via environment variable)
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
# Run the server
CMD ["node", "dist/server.js"]