-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (36 loc) · 1.31 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
# Chat Agent - AI Service (Node.js)
# Production-ready Docker image for the chat agent backend service
# ============================================
# Builder Stage - Install dependencies and build
# ============================================
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies for build)
RUN npm install
# Copy source code
COPY tsconfig.json ./
COPY src ./src
# Build TypeScript and remove dev dependencies (consolidated for layer optimization)
RUN npm run build && npm prune --omit=dev
# ============================================
# Production Stage - Minimal runtime image
# ============================================
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Copy production dependencies from builder (avoids QEMU emulation issues)
COPY --from=builder /app/node_modules ./node_modules
# Copy built application from builder
COPY --from=builder /app/dist ./dist
# Set production environment
ENV NODE_ENV=production
# Expose application port
EXPOSE 3002
# Health check
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=40s \
CMD wget --quiet --tries=1 --spider http://localhost:3002/health || exit 1
# Run the application
CMD ["node", "dist/index.js"]