# lean-ctx gateway-server image (enterprise#10/#30). # # The artifact the deploy template (root/lean-ctx-deploy Helm chart) runs: # the OSS lean-ctx binary built with the `gateway-server` feature — hardened # proxy + Postgres usage_events store + admin usage API + /metrics. No # commercial code in this image (Local-Free Invariant: self-hosting the # gateway is free; the managed control plane lives in lean-ctx-enterprise). # # Build (from the repo root): # docker build -f docker/Dockerfile.gateway -t /lean-ctx/gateway-server: . FROM rust:1-bookworm AS builder # Memory-fit defaults for Docker Desktop's 8 GiB VM: the workspace profile # (fat LTO + codegen-units=1) needs >8 GiB in the single LTO link step and # dies with ResourceExhausted. Thin LTO + 4 jobs builds comfortably; the # runtime difference is irrelevant for a network-bound proxy. CI runners # with ≥16 GiB restore the fat profile: # docker build --build-arg LTO=fat --build-arg CODEGEN_UNITS=1 --build-arg CARGO_JOBS=8 … ARG CARGO_JOBS=4 ARG LTO=thin ARG CODEGEN_UNITS=16 ENV CARGO_PROFILE_RELEASE_LTO=${LTO} \ CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CODEGEN_UNITS} WORKDIR /app # rust/ carries all compile-time data (pricing tables, compliance mappings) # that include_str! needs — one COPY covers the whole build context. COPY rust ./rust RUN cd rust && cargo build --release --features gateway-server --jobs "${CARGO_JOBS}" FROM debian:bookworm-slim # ca-certificates: outbound TLS to the LLM providers. RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* \ && useradd --system --uid 10001 --create-home --home-dir /var/lib/lean-ctx leanctx COPY --from=builder /app/rust/target/release/lean-ctx /usr/local/bin/lean-ctx USER 10001 ENV LEAN_CTX_CONFIG_DIR=/etc/lean-ctx ENV LEAN_CTX_DATA_DIR=/var/lib/lean-ctx # Proxy surface + admin listener (admin defaults to proxy port + 1). EXPOSE 8484 8485 ENTRYPOINT ["lean-ctx"] CMD ["gateway", "serve", "--port=8484", "--admin-port=8485"]