-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api
More file actions
52 lines (44 loc) · 1.98 KB
/
Copy pathDockerfile.api
File metadata and controls
52 lines (44 loc) · 1.98 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
# Dockerfile for API Server
# Uses BuildKit for better caching and performance
# syntax=docker/dockerfile:1.4
# Base stage - install dependencies
FROM node:20-alpine AS base
WORKDIR /app
# Install pnpm
# pnpm 9 matches lockfileVersion 9.0; avoid corepack on newer Node 20 patches
RUN npm install -g pnpm@9
# Copy package files (ALL workspace packages required for frozen lockfile)
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/api/package.json ./packages/api/
COPY packages/auth/package.json ./packages/auth/
COPY packages/database/package.json ./packages/database/
COPY packages/contracts/package.json ./packages/contracts/
COPY packages/interfaces/package.json ./packages/interfaces/
COPY packages/agents/package.json ./packages/agents/
COPY packages/connector/package.json ./packages/connector/
COPY packages/logger/package.json ./packages/logger/
COPY packages/scraper-core/package.json ./packages/scraper-core/
COPY packages/studio-core/package.json ./packages/studio-core/
# Create stub package.json for packages not needed by API but referenced in workspace
RUN mkdir -p packages/workers packages/web packages/e2e && \
echo '{"name":"@scholaracle/workers","version":"1.0.0"}' > packages/workers/package.json && \
echo '{"name":"@scholaracle/web","version":"1.0.0"}' > packages/web/package.json && \
echo '{"name":"@scholaracle/e2e","version":"1.0.0"}' > packages/e2e/package.json
# Install dependencies
RUN pnpm install --no-frozen-lockfile
# Development stage
FROM base AS development
COPY . .
RUN pnpm --filter @scholaracle/api... build
EXPOSE 3002
CMD ["pnpm", "--filter", "@scholaracle/api", "dev"]
# Production stage
FROM base AS production
COPY . .
RUN pnpm --filter @scholaracle/api... build
# Image-build UTC stamp for GET /api/health/version `builtAt`. After COPY so
# a new commit always gets a new time (layer cache busts with source).
RUN date -u +%Y-%m-%dT%H:%M:%SZ > /app/BUILT_AT
ENV NODE_ENV=production
EXPOSE 3002
CMD ["node", "packages/api/dist/server.js"]