From de3d355c80f7615d6ea7dd6296150c1e7e7ae754 Mon Sep 17 00:00:00 2001 From: "Angelo B. J. Luidens" Date: Wed, 3 Jun 2026 16:22:15 -0400 Subject: [PATCH] Deploy prep: Dockerfiles for admin (Next standalone) + scheduler (Bun) admin/Dockerfile: 2-stage monorepo Next.js standalone (outputFileTracingRoot added to next.config so the bundle traces workspace deps). scheduler/Dockerfile: single-stage Bun runtime, validated by a local docker build. .dockerignore excludes node_modules/.next/.turbo/.git. Build context = monorepo root; runtime env DATABASE_URL + REDIS_URL. Co-Authored-By: Claude Opus 4.8 (1M context) --- .dockerignore | 9 +++++++++ apps/admin/Dockerfile | 21 +++++++++++++++++++++ apps/admin/next.config.ts | 3 +++ apps/scheduler/Dockerfile | 13 +++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 .dockerignore create mode 100644 apps/admin/Dockerfile create mode 100644 apps/scheduler/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7e574dd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +**/node_modules +**/.next +**/.turbo +.git +**/dist +**/coverage +docs +*.md +infra/docker-compose.yml diff --git a/apps/admin/Dockerfile b/apps/admin/Dockerfile new file mode 100644 index 0000000..de425a0 --- /dev/null +++ b/apps/admin/Dockerfile @@ -0,0 +1,21 @@ +# Stargue Publishing Engine — admin dashboard (Next.js standalone, monorepo). +# Build context: the monorepo ROOT. Build: docker build -f apps/admin/Dockerfile . + +FROM oven/bun:1 AS builder +WORKDIR /app +COPY package.json bun.lock turbo.json tsconfig.json ./ +COPY packages ./packages +COPY apps ./apps +RUN bun install --frozen-lockfile +RUN bun --filter @stargue/admin run build + +FROM oven/bun:1-slim AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV PORT=3002 +# Next standalone (outputFileTracingRoot = repo root) emits apps/admin/server.js +# plus a traced node_modules under .next/standalone. +COPY --from=builder /app/apps/admin/.next/standalone ./ +COPY --from=builder /app/apps/admin/.next/static ./apps/admin/.next/static +EXPOSE 3002 +CMD ["bun", "apps/admin/server.js"] diff --git a/apps/admin/next.config.ts b/apps/admin/next.config.ts index bf2f92e..ad853d8 100644 --- a/apps/admin/next.config.ts +++ b/apps/admin/next.config.ts @@ -1,8 +1,11 @@ import type { NextConfig } from "next"; +import { join } from "node:path"; const config: NextConfig = { output: "standalone", reactStrictMode: true, + // Trace workspace deps from the monorepo root so the standalone bundle is self-contained. + outputFileTracingRoot: join(import.meta.dirname, "../../"), // The admin app is server-rendered (DB-backed, auth-gated); never statically exported. transpilePackages: ["@stargue/schema", "@stargue/sanitize", "@stargue/observability"], }; diff --git a/apps/scheduler/Dockerfile b/apps/scheduler/Dockerfile new file mode 100644 index 0000000..92a6157 --- /dev/null +++ b/apps/scheduler/Dockerfile @@ -0,0 +1,13 @@ +# Stargue Publishing Engine — scheduler (BullMQ worker, runs on Bun, no build step). +# Build context: the monorepo ROOT. Build: docker build -f apps/scheduler/Dockerfile . + +FROM oven/bun:1-slim +WORKDIR /app +ENV NODE_ENV=production +COPY package.json bun.lock turbo.json ./ +COPY packages ./packages +COPY apps ./apps +COPY db ./db +RUN bun install --frozen-lockfile +# Env required at runtime: DATABASE_URL, REDIS_URL +CMD ["bun", "apps/scheduler/src/main.ts"]