31 lines
1.2 KiB
Docker
31 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# Build context is the repo ROOT (so the bun workspace resolves).
|
|
|
|
# ---- Build: install workspace deps and bundle the backend to one file ----
|
|
FROM oven/bun:1.3.14 AS build
|
|
WORKDIR /repo
|
|
|
|
# Manifests first for cached installs.
|
|
COPY package.json bun.lock turbo.json ./
|
|
COPY packages/typescript-config/package.json ./packages/typescript-config/
|
|
COPY packages/eslint-config/package.json ./packages/eslint-config/
|
|
COPY apps/backend/package.json ./apps/backend/
|
|
COPY apps/frontend/package.json ./apps/frontend/
|
|
COPY apps/cli/package.json ./apps/cli/
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# Sources, then bundle to a self-contained dist/index.js.
|
|
COPY . .
|
|
RUN cd apps/backend && bun build src/index.ts --target bun --outdir dist
|
|
|
|
# ---- Runtime: minimal image with the bundle + baked env ----
|
|
FROM oven/bun:1.3.14-slim AS runtime
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
COPY --from=build /repo/apps/backend/dist ./dist
|
|
# Bake the production env into the image (no Secret Manager). Cloud Run injects
|
|
# PORT at runtime, which takes precedence over any value in this file.
|
|
COPY apps/backend/.env.production ./.env
|
|
EXPOSE 8080
|
|
USER bun
|
|
CMD ["bun", "dist/index.js"]
|