-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (30 loc) · 853 Bytes
/
Dockerfile
File metadata and controls
39 lines (30 loc) · 853 Bytes
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
FROM node:20-alpine AS base
WORKDIR /app
# Copy root workspace files
COPY package*.json ./
COPY client/package*.json ./client/
COPY server/package*.json ./server/
# Install all dependencies from root
RUN npm ci
# 1. Build Client
FROM base AS client-builder
COPY client/ ./client/
RUN npm run build --workspace=client
# 2. Build Server
FROM base AS server-builder
COPY server/ ./server/
RUN npm run build --workspace=server
# 3. Production Runner
FROM node:20-alpine AS runner
WORKDIR /app
# Only need production dependencies for the server
COPY package*.json ./
COPY server/package*.json ./server/
RUN npm ci --omit=dev --workspace=server
# Copy built files
COPY --from=server-builder /app/server/dist ./dist
COPY --from=client-builder /app/client/dist ./public
# Use the PORT env var
ENV PORT=3000
EXPOSE ${PORT}
CMD ["node", "dist/index.js"]