Dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # syntax=docker/dockerfile:1.7
  2. # Base = oven/bun:1.3 (Debian by default; the `-alpine` tag we previously used
  3. # is musl + busybox sh, which breaks libpg-query's native build chain — see
  4. # apps/web/Dockerfile for the full rationale).
  5. FROM oven/bun:1.3 AS base
  6. RUN apt-get update -qq && \
  7. apt-get install -y --no-install-recommends \
  8. git python3 ca-certificates build-essential nodejs npm && \
  9. rm -rf /var/lib/apt/lists/* && \
  10. update-ca-certificates
  11. RUN npm install -g pnpm@9.12.0
  12. FROM base AS build
  13. WORKDIR /repo
  14. COPY . .
  15. RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
  16. pnpm install --frozen-lockfile
  17. FROM oven/bun:1.3 AS runtime
  18. WORKDIR /app
  19. ENV NODE_ENV=production
  20. ENV BRIVEN_API_PORT=3001
  21. # MinIO client (mc) — services/minio-admin.ts shells out to it to create
  22. # per-project buckets + scoped service-account keys. Arch-matched binary.
  23. # Placed BEFORE the build-identity ARG/ENV block below: those args (BUILD_SHA/
  24. # BUILD_AT) change on every commit and would otherwise bust the cache for this
  25. # heavy download+chmod on every build. Keeping it here lands it in a stable
  26. # cached layer that only re-runs when the base image changes.
  27. RUN apt-get update -qq && apt-get install -y --no-install-recommends curl ca-certificates && \
  28. ARCH="$(dpkg --print-architecture)" && \
  29. curl -fsSL "https://dl.min.io/client/mc/release/linux-${ARCH}/mc" -o /usr/local/bin/mc && \
  30. chmod +x /usr/local/bin/mc && \
  31. rm -rf /var/lib/apt/lists/*
  32. # Optional build-time identity. Compose can pass these via:
  33. # build:
  34. # context: ../..
  35. # dockerfile: apps/api/Dockerfile
  36. # args:
  37. # BRIVEN_BUILD_SHA: ${BRIVEN_BUILD_SHA}
  38. # BRIVEN_BUILD_AT: ${BRIVEN_BUILD_AT}
  39. # When unset, /info just reports "dev" — never 500s.
  40. ARG BRIVEN_BUILD_SHA=dev
  41. ARG BRIVEN_BUILD_AT=dev
  42. ENV BRIVEN_BUILD_SHA=${BRIVEN_BUILD_SHA}
  43. ENV BRIVEN_BUILD_AT=${BRIVEN_BUILD_AT}
  44. RUN groupadd -r app && useradd -r -g app app
  45. COPY --from=build --chown=app:app /repo /app
  46. USER app
  47. EXPOSE 3001
  48. WORKDIR /app/apps/api
  49. CMD ["sh", "/app/apps/api/scripts/start.sh"]