Add the two runtime images and their compose file: `api` (Bun bundle, runs `prisma migrate deploy` before `bun run start`) and `web` (Vite build served by nginx, which proxies `/api/*` to the API and keeps the SSE streams unbuffered with a long read timeout). The database is external and both services join the `dokploy-network` for Traefik. Remove the GitHub Actions workflow: there is no hosted CI, so the verification scripts run locally.
28 lines
1.0 KiB
Docker
28 lines
1.0 KiB
Docker
# Build context is the repository root (Bun workspace monorepo).
|
|
FROM oven/bun:1.4.0 AS base
|
|
WORKDIR /app
|
|
|
|
# Manifests first so `bun install` only reruns when the lockfile changes.
|
|
FROM base AS deps
|
|
COPY package.json bun.lock bunfig.toml ./
|
|
COPY apps/api/package.json apps/api/package.json
|
|
COPY apps/web/package.json apps/web/package.json
|
|
COPY packages/shared/package.json packages/shared/package.json
|
|
RUN bun install --frozen-lockfile
|
|
|
|
FROM deps AS build
|
|
COPY . .
|
|
# `prisma.config.ts` reads DATABASE_URL at load time; generate never connects,
|
|
# so a placeholder is enough to produce the client in src/generated/.
|
|
RUN cd apps/api && DATABASE_URL="postgresql://user:pass@localhost:5432/db" bunx prisma generate
|
|
RUN cd apps/api && bun run build
|
|
|
|
# Runtime keeps the full tree: `prisma migrate deploy` runs on startup and
|
|
# needs the Prisma CLI (devDependency), prisma/ and prisma.config.ts.
|
|
FROM base AS runtime
|
|
ENV NODE_ENV=production
|
|
COPY --from=build /app /app
|
|
WORKDIR /app/apps/api
|
|
EXPOSE 4100
|
|
CMD ["sh", "-c", "bunx prisma migrate deploy && bun run start"]
|