litellm/ui/Dockerfile
Yuneng Jiang 6ef81c0bb5
fix(ui): build the dashboard once on the native platform
The UI image builds linux/amd64 and linux/arm64 on an x86_64 runner, so
the arm64 leg runs the whole Node toolchain under QEMU emulation. That
leg spent roughly 58 minutes on `npm ci` alone and never reached
`npm run build`, tripping the 60-minute job timeout and cancelling the
release before the chart could be packaged.

The builder stage does not need to be per-architecture. next.config.mjs
sets `output: "export"`, so the builder emits a static export to
/app/out; plain HTML, CSS and JS with no native artifacts. Both runtime
stages copy the same bytes, so the second, emulated build produced
identical output at enormous cost.

Pinning the builder to $BUILDPLATFORM runs it once on the runner's
native architecture. Only the nginx runtime stays multi-arch, which is
the stage that genuinely differs. Locally the full two-platform build
drops from a stall to 39 seconds, and the `npm ci` stage goes from six
scheduled lines to one, with both runtime legs still assembling.

This does not apply to gateway, backend or migrations; those compile
Python wheels, which really are architecture-specific.
2026-07-18 20:02:37 -07:00

42 lines
1.2 KiB
Docker

# syntax=docker/dockerfile:1.7
# UI container — Next.js static export served by nginx.
ARG NODE_VERSION=20.18-alpine3.20
ARG NGINX_VERSION=1.27-alpine
# ---------- builder ----------
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS builder
ENV NEXT_TELEMETRY_DISABLED=1 \
npm_config_fund=false \
npm_config_audit=false
WORKDIR /app
# Layer the lockfile-only install above the source copy so source-only
# edits don't bust the install cache.
COPY ui/litellm-dashboard/package.json ui/litellm-dashboard/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --prefer-offline
COPY ui/litellm-dashboard/ ./
RUN npm run build
# ---------- runtime ----------
FROM nginx:${NGINX_VERSION} AS runtime
# Drop the upstream default :80 server; we own the config.
RUN rm -f /etc/nginx/conf.d/default.conf
# Static export → web root.
COPY --from=builder /app/out /usr/share/nginx/html
# Routing rules — see ui/nginx.conf for the full description.
COPY ui/nginx.conf /etc/nginx/nginx.conf
EXPOSE 3000/tcp
# nginx as PID 1 in foreground; respects SIGTERM out of the box, so
# no tini/dumb-init wrapper needed.
CMD ["nginx", "-g", "daemon off;"]