| 1 | # syntax=docker/dockerfile:1 |
| 2 | # Built from the repository root: |
| 3 | # docker build -f apps/docs/Dockerfile --build-arg NEXT_PUBLIC_WEB_APP_URL=... . |
| 4 | |
| 5 | FROM oven/bun:1.3.14 AS deps |
| 6 | WORKDIR /app |
| 7 | COPY package.json bun.lock ./ |
| 8 | COPY apps/api/package.json apps/api/package.json |
| 9 | COPY apps/web/package.json apps/web/package.json |
| 10 | COPY apps/docs/package.json apps/docs/package.json |
| 11 | COPY packages/db/package.json packages/db/package.json |
| 12 | COPY packages/languages/package.json packages/languages/package.json |
| 13 | COPY packages/permissions/package.json packages/permissions/package.json |
| 14 | COPY packages/references/package.json packages/references/package.json |
| 15 | RUN bun install --frozen-lockfile |
| 16 | |
| 17 | # Bun installs the workspace, but `next build` runs on Node: the Bun runtime |
| 18 | # segfaults on this build. |
| 19 | FROM node:22-slim AS build |
| 20 | WORKDIR /app |
| 21 | COPY --from=deps /app/node_modules node_modules |
| 22 | COPY --from=deps /app/apps/docs/node_modules apps/docs/node_modules |
| 23 | COPY package.json bun.lock ./ |
| 24 | COPY apps/docs apps/docs |
| 25 | # Both are inlined into the bundle at build time, so the origins have to be |
| 26 | # known here, not at boot. |
| 27 | ARG NEXT_PUBLIC_WEB_APP_URL |
| 28 | ARG NEXT_PUBLIC_DOCS_URL |
| 29 | ENV NEXT_PUBLIC_WEB_APP_URL=$NEXT_PUBLIC_WEB_APP_URL |
| 30 | ENV NEXT_PUBLIC_DOCS_URL=$NEXT_PUBLIC_DOCS_URL |
| 31 | ENV NEXT_TELEMETRY_DISABLED=1 |
| 32 | ENV PATH=/app/node_modules/.bin:/app/apps/docs/node_modules/.bin:$PATH |
| 33 | RUN cd apps/docs && next build |
| 34 | |
| 35 | FROM node:22-slim AS runtime |
| 36 | WORKDIR /app |
| 37 | ENV NODE_ENV=production |
| 38 | ENV NEXT_TELEMETRY_DISABLED=1 |
| 39 | # `standalone` ships its own pruned node_modules; static assets are not in it. |
| 40 | COPY --from=build /app/apps/docs/.next/standalone ./ |
| 41 | COPY --from=build /app/apps/docs/.next/static ./apps/docs/.next/static |
| 42 | EXPOSE 3003 |
| 43 | ENV PORT=3003 |
| 44 | # The standalone server binds to $HOSTNAME, which container runtimes set to the |
| 45 | # container id: that is a single interface, so a platform proxy arriving on any |
| 46 | # other one is refused. Overriding it here beats a runtime-injected value, which |
| 47 | # an `ENV` line would not. |
| 48 | CMD ["sh", "-c", "export HOSTNAME=0.0.0.0; exec node apps/docs/server.js"] |