43 lines
1.6 KiB
Docker
43 lines
1.6 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# --- deps: install with bun (cacheless ephemeral runner, rely on the lockfile) ---
|
|
FROM oven/bun:1-alpine AS deps
|
|
WORKDIR /app
|
|
COPY package.json bun.lockb ./
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# --- builder: produce the Next standalone server ---
|
|
FROM oven/bun:1-alpine AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN bun run build
|
|
|
|
# --- runner: node serves the app, bun runs the migration at start ---
|
|
FROM oven/bun:1-alpine AS runner
|
|
WORKDIR /app
|
|
RUN apk add --no-cache nodejs
|
|
ENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0 NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Next standalone server + assets
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Migration bits (run via bun at container start). drizzle-orm/postgres have no runtime
|
|
# deps, so copying just these two packages is enough for scripts/migrate.ts.
|
|
COPY --from=builder /app/drizzle ./drizzle
|
|
COPY --from=builder /app/scripts ./scripts
|
|
COPY --from=builder /app/src/db ./src/db
|
|
COPY --from=builder /app/src/lib ./src/lib
|
|
COPY --from=builder /app/src/config ./src/config
|
|
COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts
|
|
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
|
COPY --from=builder /app/seed/seed.example.json ./seed/seed.example.json
|
|
COPY --from=deps /app/node_modules/drizzle-orm ./node_modules/drizzle-orm
|
|
COPY --from=deps /app/node_modules/postgres ./node_modules/postgres
|
|
|
|
EXPOSE 3000
|
|
# Apply migrations to both databases, then start the server.
|
|
CMD ["sh", "-c", "bun scripts/migrate.ts && node server.js"]
|