# 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"]
