# ── Multi-stage Dockerfile for Native Bun Runtime (web-latest-bun) ─────────── FROM oven/bun:1.3.14-slim AS base WORKDIR /app RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends \ build-essential \ python3 \ python-is-python3 \ make \ g++ \ libsecret-1-0 \ ca-certificates \ curl \ && rm -rf /var/lib/apt/lists/* # ── Builder stage (100% Bun Native Install & Build) ───────────────────────── FROM base AS builder WORKDIR /app COPY . . # Fast Bun native package install RUN bun install --include=optional --quiet # Compile native better-sqlite3 Node-API addon under Bun RUN if [ -d "node_modules/better-sqlite3" ]; then \ (cd node_modules/better-sqlite3 && bunx node-gyp rebuild); \ fi # Fetch tls-client-node native binary if script exists RUN if [ -f "node_modules/tls-client-node/scripts/postinstall.js" ]; then \ bun node_modules/tls-client-node/scripts/postinstall.js || true; \ fi # Disable Turbopack for Bun builder stage (Turbopack V8 internal worker bindings require Node) ENV OMNIROUTE_USE_TURBOPACK=0 ARG OMNIROUTE_BASE_PATH="" ENV OMNIROUTE_BASE_PATH=$OMNIROUTE_BASE_PATH ARG DASHBOARD_ALLOW_EMBED="" ENV DASHBOARD_ALLOW_EMBED=$DASHBOARD_ALLOW_EMBED ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production # Bun native Next.js build execution RUN bun run --quiet build # ── Runner stage (100% Bun Native Production Runtime) ────────────────────── FROM oven/bun:1.3.14-slim AS runner LABEL org.opencontainers.image.title="omniroute" \ org.opencontainers.image.description="Unified AI proxy — route any LLM through one endpoint (Bun Native)" \ org.opencontainers.image.url="https://omniroute.online" \ org.opencontainers.image.source="https://github.com/diegosouzapw/OmniRoute" \ org.opencontainers.image.licenses="MIT" WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends \ libsecret-1-0 \ ca-certificates \ curl \ && rm -rf /var/lib/apt/lists/* ENV NODE_ENV=production ENV PORT=20128 ENV HOSTNAME=0.0.0.0 ENV OMNIROUTE_MEMORY_MB=1024 ENV DATA_DIR=/app/data RUN mkdir -p /app/data COPY --from=builder /app/.build/next/standalone ./ COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3 ENV OMNIROUTE_MIGRATIONS_DIR=/app/migrations COPY --from=builder /app/scripts/dev/healthcheck.mjs ./healthcheck.mjs EXPOSE 20128 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ CMD bun healthcheck.mjs || exit 1 ENTRYPOINT ["bun", "bin/omniroute.mjs", "serve", "--no-open"]