Dockerfile39 lines · main
| 1 | # syntax=docker/dockerfile:1.7 |
| 2 | # Base = node:22-slim (Debian glibc), matching supabase/apps/studio/Dockerfile. |
| 3 | # Why not alpine: apps/studio depends on libpg-query@15.2.0, which (a) only has |
| 4 | # pre-built binaries for glibc-linux-x64 on supabase's S3 bucket (musl 404s), |
| 5 | # and (b) when source-compiled, runs script/buildAddon.sh which requires bash |
| 6 | # (alpine ships only busybox sh). Debian gives us glibc prebuilds AND bash. |
| 7 | FROM node:22-slim AS base |
| 8 | RUN apt-get update -qq && \ |
| 9 | apt-get install -y --no-install-recommends \ |
| 10 | git python3 ca-certificates build-essential && \ |
| 11 | rm -rf /var/lib/apt/lists/* && \ |
| 12 | update-ca-certificates |
| 13 | RUN corepack enable && corepack prepare pnpm@9.12.0 --activate |
| 14 | |
| 15 | FROM base AS build |
| 16 | WORKDIR /repo |
| 17 | # next.config.ts bakes the api-rewrite destination at build time, so the |
| 18 | # env var MUST be set here (not only at container runtime). For production |
| 19 | # it's always api.briven.tech; override at docker-build time if staging. |
| 20 | ARG BRIVEN_API_ORIGIN=https://api.briven.tech |
| 21 | ENV BRIVEN_API_ORIGIN=${BRIVEN_API_ORIGIN} |
| 22 | COPY . . |
| 23 | RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ |
| 24 | pnpm install --frozen-lockfile |
| 25 | # Bound build heap so a runaway build OOMs itself instead of swap-killing the host (kvm4 16GB). |
| 26 | ENV NODE_OPTIONS="--max-old-space-size=4096" |
| 27 | RUN pnpm --filter @briven/web... build |
| 28 | |
| 29 | FROM node:22-slim AS runtime |
| 30 | WORKDIR /app |
| 31 | ENV NODE_ENV=production |
| 32 | ENV PORT=3000 |
| 33 | ENV HOSTNAME=0.0.0.0 |
| 34 | RUN groupadd -r app && useradd -r -g app app |
| 35 | COPY --from=build --chown=app:app /repo /app |
| 36 | USER app |
| 37 | EXPOSE 3000 |
| 38 | WORKDIR /app/apps/web |
| 39 | CMD ["node", "node_modules/next/dist/bin/next", "start", "-H", "0.0.0.0", "-p", "3000"] |