mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Turbopack resolveAlias (@/mitm/manager → manager.stub.ts) was designed
for build-time safety but Next.js applies aliases to ALL imports —
including dynamic ones. This caused await import("@/mitm/manager") at
runtime to load the stub, which silently returned fake {running: true}
without spawning the MITM proxy. The UI showed "MITM proxy started"
but nothing was actually running.
Fix introduces a two-path design:
- @/mitm/manager → stub (build-time, safe for Turbopack)
- @/mitm/manager.runtime → real manager (runtime, bypasses alias)
Route handlers now dynamic-import from manager.runtime, which
re-exports from ./manager and does NOT match the alias pattern.
Additional fixes:
- Make stub throw explicit errors at runtime so misconfiguration is
immediately visible instead of silently faking success
- Add server.cjs to outputFileTracingIncludes (NFT trace) and Dockerfile
COPY so the MITM server binary exists in standalone/Docker output
78 lines
3.4 KiB
Docker
78 lines
3.4 KiB
Docker
FROM node:24.15.0-trixie-slim AS builder
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends libsecret-1-0 ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY package*.json ./
|
|
COPY scripts/postinstall.mjs ./scripts/postinstall.mjs
|
|
COPY scripts/postinstallSupport.mjs ./scripts/postinstallSupport.mjs
|
|
COPY scripts/native-binary-compat.mjs ./scripts/native-binary-compat.mjs
|
|
ENV NPM_CONFIG_LEGACY_PEER_DEPS=true
|
|
RUN if [ -f package-lock.json ]; then npm ci --no-audit --no-fund; else npm install --no-audit --no-fund; fi
|
|
|
|
COPY . ./
|
|
RUN mkdir -p /app/data && npm run build -- --webpack
|
|
|
|
FROM node:24.15.0-trixie-slim AS runner-base
|
|
WORKDIR /app
|
|
|
|
LABEL org.opencontainers.image.title="omniroute" \
|
|
org.opencontainers.image.description="Unified AI proxy — route any LLM through one endpoint" \
|
|
org.opencontainers.image.url="https://omniroute.online" \
|
|
org.opencontainers.image.source="https://github.com/diegosouzapw/OmniRoute" \
|
|
org.opencontainers.image.licenses="MIT"
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=20128
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV NODE_OPTIONS="--max-old-space-size=256"
|
|
|
|
# Data directory inside Docker — must match the volume mount in docker-compose.yml
|
|
ENV DATA_DIR=/app/data
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends libsecret-1-0 ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN mkdir -p /app/data
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/.next/standalone ./
|
|
# Explicitly copy @swc/helpers — not always traced by standalone output but needed at runtime
|
|
COPY --from=builder /app/node_modules/@swc/helpers ./node_modules/@swc/helpers
|
|
# Explicitly copy pino transport dependencies — pino spawns a worker that requires
|
|
# pino-abstract-transport at runtime; Next.js standalone trace does not capture it (#449)
|
|
COPY --from=builder /app/node_modules/pino-abstract-transport ./node_modules/pino-abstract-transport
|
|
COPY --from=builder /app/node_modules/pino-pretty ./node_modules/pino-pretty
|
|
COPY --from=builder /app/node_modules/split2 ./node_modules/split2
|
|
# Migration SQL files are read via fs.readFileSync at runtime and are NOT
|
|
# traced by Next.js standalone output — copy them explicitly.
|
|
COPY --from=builder /app/src/lib/db/migrations ./migrations
|
|
ENV OMNIROUTE_MIGRATIONS_DIR=/app/migrations
|
|
# MITM server.cjs is spawned at runtime via child_process — not traced by nft
|
|
COPY --from=builder /app/src/mitm/server.cjs ./src/mitm/server.cjs
|
|
|
|
COPY --from=builder /app/scripts/run-standalone.mjs ./run-standalone.mjs
|
|
COPY --from=builder /app/scripts/runtime-env.mjs ./runtime-env.mjs
|
|
COPY --from=builder /app/scripts/bootstrap-env.mjs ./bootstrap-env.mjs
|
|
COPY --from=builder /app/scripts/healthcheck.mjs ./healthcheck.mjs
|
|
|
|
EXPOSE 20128
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|
CMD ["node", "healthcheck.mjs"]
|
|
|
|
CMD ["node", "run-standalone.mjs"]
|
|
|
|
FROM runner-base AS runner-cli
|
|
|
|
# Install system dependencies required by openclaw (git+ssh references).
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends git ca-certificates docker.io docker-compose \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& git config --system url."https://github.com/".insteadOf "ssh://git@github.com/"
|
|
|
|
# Install CLI tools globally. Separate layer from apt for better cache reuse.
|
|
RUN npm install -g --no-audit --no-fund @openai/codex @anthropic-ai/claude-code droid openclaw@latest
|