后端建立 TypeScript 构建链路
This commit is contained in:
@@ -33,9 +33,6 @@ COPY apps/backend/package.json apps/backend/package-lock.json ./
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci
|
||||
|
||||
# --- Prune devDependencies after install ---
|
||||
RUN npm prune --omit=dev
|
||||
|
||||
# --- Playwright — install Chromium with system deps (builder has full apt) ---
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
RUN --mount=type=cache,target=/ms-playwright-cache,sharing=locked \
|
||||
@@ -47,6 +44,10 @@ RUN --mount=type=cache,target=/ms-playwright-cache,sharing=locked \
|
||||
# --- Copy application source ---
|
||||
COPY apps/backend/ ./
|
||||
|
||||
# --- Build application and prune devDependencies ---
|
||||
RUN npm run build \
|
||||
&& npm prune --omit=dev
|
||||
|
||||
# --------------------------- Runtime Stage -----------------------------------
|
||||
FROM node:22-bookworm-slim AS runtime
|
||||
|
||||
@@ -87,9 +88,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
# --- Copy artefacts from builder ---
|
||||
# Pruned node_modules (no devDeps)
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
# Application source (no build step — runs directly via `node src/index.js`)
|
||||
# Compiled application
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/src ./src
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/config ./config
|
||||
# Playwright browsers
|
||||
COPY --from=builder /ms-playwright /ms-playwright
|
||||
|
||||
Reference in New Issue
Block a user