-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
52 lines (36 loc) · 1.09 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
# Unified Dockerfile for SwapLink Server (API & Worker)
FROM node:18-alpine AS builder
WORKDIR /app
# Install pnpm
# Install pnpm and openssl
RUN apk add --no-cache openssl && npm install -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies (frozen lockfile for consistency)
RUN pnpm install --frozen-lockfile
# Copy Prisma schema and generate client
COPY prisma ./prisma
RUN pnpm db:generate
# Copy source code
COPY . .
# Build TypeScript
RUN pnpm build
# Prune dev dependencies to keep image small
ENV CI=true
RUN pnpm prune --prod
# --- Runner Stage ---
FROM node:18-alpine AS runner
WORKDIR /app
# Install openssl
RUN apk add --no-cache openssl
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Copy production node_modules from builder (preserves pnpm structure and Prisma client)
COPY --from=builder /app/node_modules ./node_modules
# Copy built artifacts
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
# Expose API port
EXPOSE 3000
# Default command (can be overridden in docker-compose)
CMD ["node", "dist/api/server.js"]