forked from zaber-dev/free-ai-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (41 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (41 loc) · 1.58 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
# =================================================================
# Stage 1: Build & Compile TypeScript Monorepo
# =================================================================
FROM node:20-alpine AS builder
WORKDIR /app
# Copy root workspace configurations and package files
COPY package*.json tsconfig.base.json ./
COPY packages/core/package*.json ./packages/core/
COPY packages/mcp/package*.json ./packages/mcp/
COPY apps/gateway/package*.json ./apps/gateway/
RUN npm ci
# Copy sources
COPY packages/ ./packages/
COPY apps/ ./apps/
# Build all workspace packages
RUN npm run build --workspaces
# =================================================================
# Stage 2: Production Runtime
# =================================================================
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOST=0.0.0.0
# Install production dependencies only
COPY package*.json ./
COPY packages/core/package*.json ./packages/core/
COPY packages/mcp/package*.json ./packages/mcp/
COPY apps/gateway/package*.json ./apps/gateway/
RUN npm ci --omit=dev && npm cache clean --force
# Copy compiled JavaScript and configuration files
COPY --from=builder /app/packages/core/dist ./packages/core/dist
COPY --from=builder /app/packages/core/src/config ./packages/core/src/config
COPY --from=builder /app/apps/gateway/dist ./apps/gateway/dist
# Create state directory for persistent quota snapshots
RUN mkdir -p /app/state && chown -R node:node /app
# Switch to non-root user for security
USER node
EXPOSE 3000
# Start server
CMD ["node", "apps/gateway/dist/index.js"]