Dockerfile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. FROM base AS build
  15. WORKDIR /repo
  16. # next.config.ts bakes the api-rewrite destination at build time, so the
  17. # env var MUST be set here (not only at container runtime). For production
  18. # it's always api.briven.tech; override at docker-build time if staging.
  19. ARG BRIVEN_API_ORIGIN=https://api.briven.tech
  20. ENV BRIVEN_API_ORIGIN=${BRIVEN_API_ORIGIN}
  21. COPY . .
  22. RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
  23. pnpm install --frozen-lockfile
  24. # Bound build heap so a runaway build OOMs itself instead of swap-killing the host (kvm4 16GB).
  25. ENV NODE_OPTIONS="--max-old-space-size=4096"
  26. RUN pnpm --filter @briven/web... build
  27. FROM node:22-slim AS runtime
  28. WORKDIR /app
  29. ENV NODE_ENV=production
  30. ENV PORT=3000
  31. ENV HOSTNAME=0.0.0.0
  32. RUN groupadd -r app && useradd -r -g app app
  33. COPY --from=build --chown=app:app /repo /app
  34. USER app
  35. EXPOSE 3000
  36. WORKDIR /app/apps/web
  37. CMD ["node", "node_modules/next/dist/bin/next", "start", "-H", "0.0.0.0", "-p", "3000"]