Dockerfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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.
  4. FROM oven/bun:1.3 AS base
  5. RUN 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
  10. RUN npm install -g pnpm@9.12.0
  11. FROM base AS build
  12. WORKDIR /repo
  13. COPY . .
  14. RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
  15. pnpm install --frozen-lockfile
  16. FROM oven/bun:1.3 AS runtime
  17. WORKDIR /app
  18. ENV NODE_ENV=production
  19. ENV BRIVEN_RUNTIME_PORT=3003
  20. RUN groupadd -r app && useradd -r -g app app
  21. COPY --from=build --chown=app:app /repo /app
  22. # The runtime executes each user function inside a locked-down Deno isolate
  23. # (BRIVEN_RUNTIME_EXECUTOR=deno — the multi-tenant security boundary). The base
  24. # image is Bun, so the `deno` binary is copied in from Deno's official image.
  25. # Without it the executor fails with: Executable not found in $PATH: "deno".
  26. COPY --from=denoland/deno:bin-2.8.3 /deno /usr/local/bin/deno
  27. # Create the bundle dir and chown it BEFORE switching to the non-root user.
  28. # compose mounts the `runtime_bundles` named volume at /var/lib/briven/bundles;
  29. # a fresh named volume inherits the ownership of this image directory on first
  30. # creation, so it must already be app:app or the non-root process gets EACCES
  31. # when it mkdir's the per-project bundle subfolder (bundle_fetch_failed).
  32. RUN mkdir -p /var/lib/briven/bundles && chown -R app:app /var/lib/briven
  33. USER app
  34. EXPOSE 3003
  35. WORKDIR /app/apps/runtime
  36. CMD ["bun", "run", "src/index.ts"]