Dockerfile38 lines · main
1# syntax=docker/dockerfile:1.7
2# Base = oven/bun:1.3 (Debian) — see apps/web/Dockerfile for the libpg-query
3# alpine-vs-debian rationale.
4FROM oven/bun:1.3 AS base
5RUN apt-get update -qq && \
6 apt-get install -y --no-install-recommends \
7 git python3 ca-certificates build-essential nodejs npm && \
8 rm -rf /var/lib/apt/lists/* && \
9 update-ca-certificates
10RUN npm install -g pnpm@9.12.0
11
12FROM base AS build
13WORKDIR /repo
14COPY . .
15RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
16 pnpm install --frozen-lockfile
17
18FROM oven/bun:1.3 AS runtime
19WORKDIR /app
20ENV NODE_ENV=production
21ENV BRIVEN_RUNTIME_PORT=3003
22RUN groupadd -r app && useradd -r -g app app
23COPY --from=build --chown=app:app /repo /app
24# The runtime executes each user function inside a locked-down Deno isolate
25# (BRIVEN_RUNTIME_EXECUTOR=deno — the multi-tenant security boundary). The base
26# image is Bun, so the `deno` binary is copied in from Deno's official image.
27# Without it the executor fails with: Executable not found in $PATH: "deno".
28COPY --from=denoland/deno:bin-2.8.3 /deno /usr/local/bin/deno
29# Create the bundle dir and chown it BEFORE switching to the non-root user.
30# compose mounts the `runtime_bundles` named volume at /var/lib/briven/bundles;
31# a fresh named volume inherits the ownership of this image directory on first
32# creation, so it must already be app:app or the non-root process gets EACCES
33# when it mkdir's the per-project bundle subfolder (bundle_fetch_failed).
34RUN mkdir -p /var/lib/briven/bundles && chown -R app:app /var/lib/briven
35USER app
36EXPOSE 3003
37WORKDIR /app/apps/runtime
38CMD ["bun", "run", "src/index.ts"]