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.
7FROM node:22-slim AS base
8RUN 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
13RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
14
15FROM base AS build
16WORKDIR /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.
20ARG BRIVEN_API_ORIGIN=https://api.briven.tech
21ENV BRIVEN_API_ORIGIN=${BRIVEN_API_ORIGIN}
22COPY . .
23RUN --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).
26ENV NODE_OPTIONS="--max-old-space-size=4096"
27RUN pnpm --filter @briven/web... build
28
29FROM node:22-slim AS runtime
30WORKDIR /app
31ENV NODE_ENV=production
32ENV PORT=3000
33ENV HOSTNAME=0.0.0.0
34RUN groupadd -r app && useradd -r -g app app
35COPY --from=build --chown=app:app /repo /app
36USER app
37EXPOSE 3000
38WORKDIR /app/apps/web
39CMD ["node", "node_modules/next/dist/bin/next", "start", "-H", "0.0.0.0", "-p", "3000"]