docker: build server-dist in builder stage; run-time uses built server; keep client dist prebuilt
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,3 +1,22 @@
|
|||||||
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
|
# Install pnpm
|
||||||
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install all deps for building server
|
||||||
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copy only server sources and tsconfig for server build
|
||||||
|
COPY src/server ./src/server
|
||||||
|
COPY tsconfig.server.json ./tsconfig.server.json
|
||||||
|
COPY tsconfig.server.build.json ./tsconfig.server.build.json
|
||||||
|
|
||||||
|
# Build server only (no client build)
|
||||||
|
RUN pnpm tsc -p tsconfig.server.build.json
|
||||||
|
|
||||||
FROM node:22-alpine AS production
|
FROM node:22-alpine AS production
|
||||||
|
|
||||||
# Install pnpm and required runtime tools
|
# Install pnpm and required runtime tools
|
||||||
@@ -14,7 +33,8 @@ RUN pnpm install --frozen-lockfile --prod
|
|||||||
|
|
||||||
# Copy prebuilt application artifacts from repository (no TS build in image)
|
# Copy prebuilt application artifacts from repository (no TS build in image)
|
||||||
COPY dist ./dist
|
COPY dist ./dist
|
||||||
COPY server-dist ./server-dist
|
# Use freshly built server from builder stage
|
||||||
|
COPY --from=builder /app/server-dist ./server-dist
|
||||||
COPY public ./public
|
COPY public ./public
|
||||||
|
|
||||||
# Copy necessary runtime files
|
# Copy necessary runtime files
|
||||||
|
Reference in New Issue
Block a user