🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
Revert "feat(docker): build FIPS images on Iron Bank Alpine instead of UBI 9" (#18449)
Steffen Reutherf964009483c7
diff --git a/.github/workflows/_deploy_ecs_service.yml b/.github/workflows/_deploy_ecs_service.ymlindex c27bf44315..55ad829026 100644--- a/.github/workflows/_deploy_ecs_service.yml+++ b/.github/workflows/_deploy_ecs_service.yml@@ -31,8 +31,9 @@ jobs:permissions:contents: readenv:- # Iron Bank Alpine base, the same one pipeline.yml uses for release images.- BASE_IMAGE: registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24+ # Iron Bank UBI 9 bases, the same ones pipeline.yml uses for release images.+ BASE_IMAGE: registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8+ MICRO_BASE_IMAGE: registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8steps:- name: Get app nameuses: winterjung/split@a211a1c46e35fcdc4097d59dd6282d4a9859651b # v2@@ -73,6 +74,7 @@ jobs:--target runtime \--build-arg BUILD_ID="$IMAGE_TAG" \--build-arg BASE_IMAGE="$BASE_IMAGE" \+ --build-arg MICRO_BASE_IMAGE="$MICRO_BASE_IMAGE" \-t "$REGISTRY/ai-gateway:$IMAGE_TAG" \./ai-gatewaydocker push "$REGISTRY/ai-gateway:$IMAGE_TAG"@@ -102,6 +104,7 @@ jobs:-t $REGISTRY/$REPOSITORY:$IMAGE_TAG \-f ./${STEPS_SPLIT_OUTPUTS__0}/Dockerfile \--build-arg BASE_IMAGE="$BASE_IMAGE" \+ --build-arg MICRO_BASE_IMAGE="$MICRO_BASE_IMAGE" \--build-arg NEXT_PUBLIC_LANGFUSE_CLOUD_REGION=${VARS_NEXT_PUBLIC_LANGFUSE_CLOUD_REGION} \--build-arg NEXT_LANGFUSE_TRACING_SAMPLE_RATE=${VARS_NEXT_LANGFUSE_TRACING_SAMPLE_RATE} \--build-arg NEXT_PUBLIC_SENTRY_ENVIRONMENT=${VARS_NEXT_PUBLIC_SENTRY_ENVIRONMENT} \diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex 2c2a25f5f0..23db39b61e 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -645,9 +645,9 @@ jobs:password: ${{ secrets.DOCKERHUB_TOKEN_READ }}# Iron Bank needs a registry1.dso.mil account, and those credentials are# not available to forks or to pull_request runs from a fork. Fall back- # to the Dockerfile default, the public Alpine image, on which the- # Dockerfile compiles the same OpenSSL 3.1.2 FIPS provider from source.- - name: Resolve FIPS base image+ # to the Dockerfile default, Red Hat's public UBI9, which has the same+ # content and the same FIPS-validated OpenSSL.+ - name: Resolve FIPS base imagesid: basesenv:IRONBANK_USER: ${{ secrets.IRONBANK_USER }}@@ -658,7 +658,8 @@ jobs:run: |if [ -n "$IRONBANK_USER" ]; thenecho "ironbank=true" >> "$GITHUB_OUTPUT"- echo "base=registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24" >> "$GITHUB_OUTPUT"+ echo "base=registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8" >> "$GITHUB_OUTPUT"+ echo "micro=registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8" >> "$GITHUB_OUTPUT"elif [ "$SECRETS_EXPECTED" = "true" ]; then# Never degrade quietly where the credential is supposed to be# present: a green build on the wrong base misreports which image@@ -666,9 +667,10 @@ jobs:echo "::error::IRONBANK_USER is empty on a run that should have it. Check the repository secrets." >&2exit 1else- echo "Fork run without Registry1 access, building on the public Alpine image." >&2+ echo "Fork run without Registry1 access, building on Red Hat's public UBI9." >&2echo "ironbank=false" >> "$GITHUB_OUTPUT"- echo "base=alpine:3.24" >> "$GITHUB_OUTPUT"+ echo "base=registry.access.redhat.com/ubi9/ubi:9.8" >> "$GITHUB_OUTPUT"+ echo "micro=registry.access.redhat.com/ubi9/ubi-micro:9.8" >> "$GITHUB_OUTPUT"fi- name: Login to Iron Bankif: steps.bases.outputs.ironbank == 'true'@@ -692,16 +694,19 @@ jobs:# Type-checking runs in the lint job; release builds retain it.env:BASE_IMAGE: ${{ steps.bases.outputs.base }}+ MICRO_BASE_IMAGE: ${{ steps.bases.outputs.micro }}run: |docker compose -f "$DOCKER_COMPOSE_FILE" build --print > /tmp/bake.jsonif [ "${{ matrix.component }}" = "web" ]; thendocker buildx bake -f /tmp/bake.json \--set "*.args.BASE_IMAGE=$BASE_IMAGE" \+ --set "*.args.MICRO_BASE_IMAGE=$MICRO_BASE_IMAGE" \--set "langfuse-web.args.NEXT_IGNORE_BUILD_ERRORS=true" \langfuse-webelsedocker buildx bake -f /tmp/bake.json \--set "*.args.BASE_IMAGE=$BASE_IMAGE" \+ --set "*.args.MICRO_BASE_IMAGE=$MICRO_BASE_IMAGE" \langfuse-workerfi- name: Start compose services and wait for healthchecks@@ -1052,11 +1057,10 @@ jobs:LANGFUSE_CODE_EVAL_AWS_LAMBDA_ENDPOINT: ${{ matrix.deploy-mode == '' && 'http://localhost:4566' || '' }}tests-fips:- # Runs the web and worker suites the way a FIPS deployment would: on the- # Alpine toolchain from worker/Dockerfile, where scripts/ci/fips-tests.sh- # starts Langfuse and the tests with OPENSSL_CONF=/etc/ssl/openssl-fips.cnf,- # the config the image entrypoints select for LANGFUSE_REQUIRE_FIPS=true.- # Code paths that need an algorithm FIPS refuses (md5, ...) fail with+ # Runs the web and worker suites the way a FIPS host would: on the UBI+ # toolchain from worker/Dockerfile with OPENSSL_FORCE_FIPS_MODE=1, which+ # puts Red Hat's OpenSSL in FIPS mode without a FIPS kernel. Code paths+ # that need an algorithm FIPS refuses (md5, ...) fail with# ERR_OSSL_EVP_UNSUPPORTED. Databases and migrations run on the runner as# in tests-web/tests-worker; install, build, the web and worker processes# and the tests run in the container (scripts/ci/fips-tests.sh).@@ -1108,7 +1112,7 @@ jobs:cache-dependency-path: "pnpm-lock.yaml"- name: install dependencies# For the migrations and seeding on the runner; the container installs- # its own copy for Alpine.+ # its own copy for UBI.run: |pnpm install- name: Install golang-migrate for Clickhouse migrations@@ -1134,7 +1138,7 @@ jobs:uses: useblacksmith/setup-docker-builder@1e75355f81cbb3f93cba1eb5dd5e5b05110ca8f9 # v2.0.1with:cache-key: langfuse/test-fips-toolchain- - name: Build Alpine toolchain image+ - name: Build UBI toolchain imagerun: docker buildx build --load --target toolchain -f worker/Dockerfile -t langfuse-fips-toolchain .- name: Run + migraterun: |@@ -1167,6 +1171,7 @@ jobs:SUITE: ${{ matrix.suite }}run: |docker run --rm --network host \+ -e OPENSSL_FORCE_FIPS_MODE=1 \-e CI -e VITEST_MAX_WORKERS -e LANGFUSE_CODE_EVAL_AWS_LAMBDA_ENDPOINT \-e PNPM_STORE_DIR=/pnpm-store \-v "$(pnpm store path --silent):/pnpm-store" \@@ -1709,10 +1714,10 @@ jobs:with:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_TOKEN }}- # Released images always build on the Iron Bank base. Its Alpine image- # is built for linux/amd64 and linux/arm64, so every leg of the platform- # matrix resolves there.- - name: Resolve FIPS base image+ # Released images always build on the Iron Bank bases. Both ubi9 and+ # ubi9-micro publish an OCI index covering linux/amd64 and linux/arm64,+ # so every leg of the platform matrix resolves there.+ - name: Resolve FIPS base imagesid: basesenv:IRONBANK_USER: ${{ secrets.IRONBANK_USER }}@@ -1725,7 +1730,8 @@ jobs:echo "::error::IRONBANK_USER is empty on a release build. Check the repository secrets." >&2exit 1fi- echo "base=registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24" >> "$GITHUB_OUTPUT"+ echo "base=registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8" >> "$GITHUB_OUTPUT"+ echo "micro=registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8" >> "$GITHUB_OUTPUT"- name: Log in to Iron Bankuses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0with:@@ -1773,6 +1779,7 @@ jobs:platforms: ${{ matrix.platform }}build-args: |BASE_IMAGE=${{ steps.bases.outputs.base }}+ MICRO_BASE_IMAGE=${{ steps.bases.outputs.micro }}provenance: falsesbom: false- name: Build and push image by digest to Docker Hub (${{ matrix.component }}, ${{ matrix.platform_tag }})@@ -1786,6 +1793,7 @@ jobs:platforms: ${{ matrix.platform }}build-args: |BASE_IMAGE=${{ steps.bases.outputs.base }}+ MICRO_BASE_IMAGE=${{ steps.bases.outputs.micro }}provenance: falsesbom: false- name: Record pushed digestsdiff --git a/ai-gateway/Dockerfile b/ai-gateway/Dockerfileindex dc5a659887..4e72ff3a99 100644--- a/ai-gateway/Dockerfile+++ b/ai-gateway/Dockerfile@@ -1,55 +1,54 @@-# FIPS 140-3 base: Alpine builder and runtime+# FIPS 140-3 base: UBI 9 builder and ubi9-micro runtime# The gateway performs no TLS today (plain HTTP; the dependency graph contains# no openssl or rustls crates), so FIPS readiness here means the whole image-# lifecycle stays on one platform: the binary is compiled and dynamically-# linked against Alpine's musl, so outbound TLS added later links the system-# libcrypto.so.3 and can use the OpenSSL 3.1.2 FIPS provider (CMVP certificate-# #4985) that Iron Bank's Alpine ships, the same pattern Alpine's Node uses in-# web/worker. The crypto config stays at the base image's default until the-# gateway does TLS.-# The default is the public Alpine image, so the build needs no credentials.-# Iron Bank's Alpine compiles the FIPS provider from the validated source and-# serves it from an authenticated registry with DoD provenance and scan-# attestations. Release builds opt in after `docker login registry1.dso.mil`-# (free P1 account plus a CLI secret):-# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24-ARG BASE_IMAGE=alpine:3.24+# lifecycle stays on the RHEL platform: the binary is compiled and linked+# against UBI9 glibc, and the runtime carries the CMVP-validated OpenSSL FIPS+# provider, so outbound TLS added later links the system libcrypto.so.3 and+# inherits the validated module, the same pattern the RPM Node uses in+# web/worker. The crypto policy stays at the default until the gateway does TLS.+# The defaults are Red Hat's public UBI9 images, so the build needs no+# credentials. Iron Bank serves the same content from an authenticated registry+# with DoD provenance and scan attestations. Release builds opt in by overriding+# both args after `docker login registry1.dso.mil` (free P1 account plus a CLI+# secret):+# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8+# --build-arg MICRO_BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8+ARG BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:9.8+ARG MICRO_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-micro:9.8FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS builderARG TARGETARCH-# gcc and musl-dev provide the linker and C runtime objects; bash runs the-# toolchain installer (busybox wget fetches it). Alpine's own rust package-# trails the version rust-toolchain.toml pins, so the toolchain comes from the-# standalone installer below.-RUN apk upgrade --no-cache && \- apk add --no-cache gcc musl-dev bash+# gcc provides the linker; tar and gzip unpack the pinned toolchain (curl is+# already present as curl-minimal in the base). Red Hat's UBI9 rust-toolset+# (1.84.1) cannot compile this crate's edition 2024 (needs rustc >= 1.85), and+# the official rust:1.98.0-bookworm image links against Debian's glibc 2.36,+# so binaries built there refuse to run on UBI9 (glibc 2.34). Building on UBI9+# keeps the toolchain and the binary on the FIPS-validated platform.+RUN dnf -y upgrade && \+ dnf -y install --setopt=install_weak_deps=0 gcc tar gzip && \+ dnf clean all# Pinned standalone Rust 1.98.0 installer, the exact channel from-# rust-toolchain.toml (keep the version in sync with it), checksum-verified.-# rustup-init would fetch the rustup binary from an unversioned URL, and only-# rustc, cargo and the target's std are needed to build; docs, clippy and-# rustfmt stay out of the builder image (CI runs fmt and clippy outside-# Docker).+# rust-toolchain.toml (keep the version in sync with it), checksum-verified+# like the dumb-init binary in web/Dockerfile. rustup-init would fetch the+# rustup binary from an unversioned URL, and only rustc, cargo and the+# target's std are needed to build; docs, clippy and rustfmt stay out of the+# builder image (CI runs fmt and clippy outside Docker).RUN set -eux; \case "${TARGETARCH:-amd64}" in \- amd64) triple=x86_64-unknown-linux-musl; toolchain_sha256=b2cf07e41d4747ddf3b20962ca9de2a08da00646f55ab4c1b51cef99895bae0a ;; \- arm64) triple=aarch64-unknown-linux-musl; toolchain_sha256=c26e37bb6f20e49498c552e53e3f34871ba2f7610c7f8b2cce38a48e3570c7de ;; \+ amd64) triple=x86_64-unknown-linux-gnu; toolchain_sha256=aa30409afa67bd1ada244cefd82c7980e6a65bc113bb978e934b2413c75e3900 ;; \+ arm64) triple=aarch64-unknown-linux-gnu; toolchain_sha256=5fbb4282403046d52a4672765c6761a809bf9f33e699b17e6eb7a93ab7770cc3 ;; \*) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \esac; \- wget -qO /tmp/rust.tar.gz "https://static.rust-lang.org/dist/rust-1.98.0-${triple}.tar.gz"; \+ curl -fsSL -o /tmp/rust.tar.gz "https://static.rust-lang.org/dist/rust-1.98.0-${triple}.tar.gz"; \echo "${toolchain_sha256} /tmp/rust.tar.gz" | sha256sum -c -; \tar -xzf /tmp/rust.tar.gz -C /tmp; \/tmp/rust-1.98.0-${triple}/install.sh --prefix=/usr/local \--components=rustc,cargo,rust-std-${triple}; \rm -rf /tmp/rust.tar.gz /tmp/rust-1.98.0-${triple}-# rustc links musl targets statically by default; link dynamically instead so-# an OpenSSL dependency added later uses the system libcrypto.so.3 rather than-# a bundled copy.-ENV RUSTFLAGS="-C target-feature=-crt-static"-WORKDIR /appCOPY Cargo.toml Cargo.lock rust-toolchain.toml ./@@ -60,23 +59,37 @@ COPY src ./src# 1.98.0 toolchain and the checked-in lockfile.RUN cargo build --release --locked-# The runtime image carries no package manager, python, or curl: apk-tools is-# removed after the install below, and its database stays for scanners.-FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS runtime+# Runtime rootfs assembled with dnf --installroot and layered onto ubi9-micro:+# the final image carries no package manager, python, or curl. It holds only+# the packages listed below plus their deps, with an intact rpmdb for scanners.+# --disableexcludes=all: the Iron Bank base excludes filesystem-* in+# /etc/dnf/dnf.conf (it protects its own rootfs during in-place upgrades),+# which would also block installing the dir-skeleton package into a fresh+# installroot.+FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS rpm-installer++# glibc and libgcc are the binary's dynamic dependencies (libgcc_s for panics).+# openssl-libs ships the FIPS provider module (/usr/lib64/ossl-modules/fips.so),+# unlinked by today's binary but required the moment an OpenSSL-dependent+# binary lands, so the validated module is already present. crypto-policies+# provides the system policy OpenSSL reads; ca-certificates is the trust store+# for future outbound TLS. wget serves the ECS container health command+# (`sh -c 'wget -qO /dev/null http://localhost:8080/health'`, exercised by+# scripts/smoke-image.sh); ubi9-micro already provides the shell.+RUN dnf -y --installroot /mnt/rootfs --releasever 9 --setopt=install_weak_deps=0 \+ --setopt=tsflags=nodocs --disableexcludes=all \+ install glibc libgcc ca-certificates crypto-policies openssl-libs wget && \+ dnf --installroot /mnt/rootfs clean all && \+ rm -rf /mnt/rootfs/var/cache /mnt/rootfs/var/log/dnf*++# Bake the non-root user into the rootfs (micro has no shadow-utils). uid/gid+# 10001 preserves the upstream gateway image's identity.+RUN echo "gateway:x:10001:" >> /mnt/rootfs/etc/group && \+ echo "gateway:x:10001:10001::/home/gateway:/sbin/nologin" >> /mnt/rootfs/etc/passwd-# libgcc is the binary's one dynamic dependency besides musl (libgcc_s for-# panics). ca-certificates is the trust store for future outbound TLS.-# busybox (in the base) provides the shell. GNU wget serves the ECS container-# health command (`sh -c 'wget -qO /dev/null http://localhost:8080/health'`,-# exercised by scripts/smoke-image.sh): busybox wget only tries the first-# address `localhost` resolves to, ::1, where the gateway does not listen.-# uid/gid 10001 preserves the upstream gateway image's identity.-RUN apk upgrade --no-cache && \- apk add --no-cache libgcc ca-certificates wget && \- addgroup -S -g 10001 gateway && \- adduser -S -D -H -u 10001 -G gateway -h /home/gateway -s /sbin/nologin gateway && \- apk del --no-cache apk-tools+FROM --platform=${TARGETPLATFORM:-linux/amd64} ${MICRO_BASE_IMAGE} AS runtime+COPY --from=rpm-installer /mnt/rootfs /COPY --from=builder /app/target/release/ai-gateway /usr/local/bin/ai-gatewayARG BUILD_IDENV BUILD_ID=$BUILD_IDdiff --git a/packages/native/AGENTS.md b/packages/native/AGENTS.mdindex 9fcb5f2c23..036219302f 100644--- a/packages/native/AGENTS.md+++ b/packages/native/AGENTS.md@@ -13,8 +13,8 @@them; rebuild and commit the result whenever `src/lib.rs` exports change.- Building the worker needs the pinned Rust toolchain: CI runners get it fromrustup auto-install on first `cargo` use; `worker/Dockerfile` installs the- same version from the checksum-pinned standalone musl installer on Alpine.- Bump `rust-toolchain.toml` together with that version and both per-arch sha256+ same version from the checksum-pinned standalone installer on UBI9. Bump+ `rust-toolchain.toml` together with that version and both per-arch sha256values (`https://static.rust-lang.org/dist/rust-<version>-<triple>.tar.gz.sha256`).The pin starts equal to `ai-gateway/rust-toolchain.toml` but the files aredeliberately separate.diff --git a/packages/native/README.md b/packages/native/README.mdindex 2748ce9264..2b0e28c1ef 100644--- a/packages/native/README.md+++ b/packages/native/README.md@@ -80,8 +80,8 @@ is always present when the worker starts or its tests run. A direct## How it ships`worker/Dockerfile` installs the toolchain pinned in `rust-toolchain.toml` from-the checksum-verified standalone Rust installer into its Alpine builder stage;-`turbo run build --filter=worker...` compiles the addon for musl, and+the checksum-verified standalone Rust installer into its UBI9 builder stage;+`turbo run build --filter=worker...` compiles the addon for glibc, and`pnpm deploy` copies the `.node` file into the runtime image next to theloader. Each architecture builds on a native runner, so no crosscompilation is involved. The runtime image gains only the compiled library.diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex eae9f418c6..8796ba524e 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -4,10 +4,10 @@generator client {provider = "prisma-client-js"previewFeatures = ["views", "relationJoins", "metrics"]- // native resolves to linux-musl(-arm64)-openssl-3.0.x in the Alpine image- // builds; those engines link the system libcrypto.so.3, so Postgres TLS can- // run inside the image's FIPS-validated OpenSSL provider.- binaryTargets = ["native"]+ // rhel-openssl-3.0.x: UBI9 runtime images (glibc); these engines link the+ // system libcrypto.so.3, so Postgres TLS runs inside the platform's+ // FIPS-validated OpenSSL module.+ binaryTargets = ["native", "rhel-openssl-3.0.x"]}datasource db {diff --git a/packages/shared/src/server/ee/fips/assertFipsMode.ts b/packages/shared/src/server/ee/fips/assertFipsMode.tsindex 8e8c61e3d6..d84057647e 100644--- a/packages/shared/src/server/ee/fips/assertFipsMode.ts+++ b/packages/shared/src/server/ee/fips/assertFipsMode.ts@@ -7,9 +7,8 @@ import { isEnterpriseLicenseAvailable } from "../licenseCheck";** Fails closed: when FIPS mode is requested, startup must stop unless an* enterprise license is available and Node's OpenSSL FIPS provider is active.- * The provider is active when OpenSSL loads the image's- * /etc/ssl/openssl-fips.cnf, which the image entrypoints select through- * OPENSSL_CONF.+ * The provider is only active when the host kernel runs in FIPS mode, so a+ * container cannot switch it on by itself.** Imports nothing that opens connections, so callers can run it before any* other startup code.@@ -29,7 +28,7 @@ export function assertFipsMode(envOverride?: SharedEnv): void {if (getFips() !== 1) {throw new Error(- "LANGFUSE_REQUIRE_FIPS=true but Node's OpenSSL FIPS provider is not active (crypto.getFips() != 1). Start the Langfuse image through its entrypoint or set OPENSSL_CONF=/etc/ssl/openssl-fips.cnf.",+ "LANGFUSE_REQUIRE_FIPS=true but Node's OpenSSL FIPS provider is not active (crypto.getFips() != 1). Run Langfuse on a host with FIPS mode enabled.",);}}diff --git a/scripts/ci/fips-tests.sh b/scripts/ci/fips-tests.shindex bd8df20c79..5f151f8cef 100755--- a/scripts/ci/fips-tests.sh+++ b/scripts/ci/fips-tests.sh@@ -3,21 +3,14 @@# code path that needs an algorithm a FIPS host refuses (md5, ...) fails here# with ERR_OSSL_EVP_UNSUPPORTED instead of in a customer deployment.#-# Runs inside the Alpine toolchain stage of worker/Dockerfile: Alpine's Node-# links the system OpenSSL, and OPENSSL_CONF=/etc/ssl/openssl-fips.cnf loads the-# image's FIPS provider for it and every other OpenSSL user it starts. The-# databases, migrations and env files must already be set up on the host, as-# the tests-fips CI job does.-#-# FIPS mode covers the Langfuse processes and the tests, not the build, which-# matches the images: their build stages run without it too. The standalone-# Rust toolchain's cargo statically links its own OpenSSL, which reads-# OPENSSL_CONF but cannot load the provider module, and then fails with-# "library has no ciphers".+# Runs inside the UBI toolchain stage of worker/Dockerfile: Red Hat's Node links+# the system OpenSSL, and OPENSSL_FORCE_FIPS_MODE=1 switches it into FIPS mode+# without a FIPS host kernel. The databases, migrations and env files must+# already be set up on the host, as the tests-fips CI job does.## Local run, from the repo root with the dev containers up and migrated:# docker buildx build --load --target toolchain -f worker/Dockerfile -t langfuse-fips-toolchain .-# docker run --rm --network host -v "$PWD:/src:ro" \+# docker run --rm --network host -e OPENSSL_FORCE_FIPS_MODE=1 -v "$PWD:/src:ro" \# langfuse-fips-toolchain bash /src/scripts/ci/fips-tests.sh worker [vitest filters...]set -euo pipefail@@ -26,22 +19,19 @@ readonly SUITE="${1:?usage: fips-tests.sh web|worker [vitest filters...]}"shiftreadonly SRC_DIR="${FIPS_SOURCE_DIR:-/src}"readonly WORK_DIR="/work"-readonly FIPS_OPENSSL_CONF="/etc/ssl/openssl-fips.cnf"export HUSKY=0 TURBO_TELEMETRY_DISABLED=1-unset OPENSSL_CONFgroup() { echo "::group::$*"; }endgroup() { echo "::endgroup::"; }-# Fail before the slow install and build when the image has no FIPS provider.-if ! OPENSSL_CONF="$FIPS_OPENSSL_CONF" node -e 'process.exit(require("node:crypto").getFips() === 1 ? 0 : 1)'; then- echo "The OpenSSL FIPS provider is not active with OPENSSL_CONF=$FIPS_OPENSSL_CONF." >&2+if ! node -e 'process.exit(require("node:crypto").getFips() === 1 ? 0 : 1)'; then+ echo "The OpenSSL FIPS provider is not active; run with OPENSSL_FORCE_FIPS_MODE=1." >&2exit 1fi# Build on a private copy: the host's node_modules and build outputs were made-# for the host, not for Alpine. Env files written by the host come along.+# for the host, not for UBI. Env files written by the host come along.group "Copy sources"mkdir -p "$WORK_DIR"tar -C "$SRC_DIR" --exclude=.git --exclude=node_modules --exclude=.next \@@ -78,7 +68,6 @@ case "$SUITE" inpnpm --filter=worker... run buildendgroup- export OPENSSL_CONF="$FIPS_OPENSSL_CONF"NODE_ENV="test" pnpm --filter @langfuse/shared run test --passWithNoTests "$@"pnpm --filter=worker run test:exclude-llm-connections --passWithNoTests "$@";;@@ -97,7 +86,6 @@ case "$SUITE" inpnpm --filter web run build:otel-workerendgroup- export OPENSSL_CONF="$FIPS_OPENSSL_CONF"group "Start Langfuse"# Docker sets HOSTNAME to the container's host name, and the worker binds# to HOSTNAME; bind all interfaces so localhost reaches it.diff --git a/web/Dockerfile b/web/Dockerfileindex e7820b8bcd..5eaa232d18 100644--- a/web/Dockerfile+++ b/web/Dockerfile@@ -1,89 +1,30 @@-# FIPS 140-3 base: Alpine with the distribution's nodejs package instead of-# node:24-alpine. Alpine's Node dynamically links the system libcrypto.so.3, so-# node:crypto routes through the OpenSSL 3.1.2 FIPS provider-# (/usr/lib/ossl-modules/fips.so, CMVP certificate #4985). Upstream node images+# FIPS 140-3 base: UBI 9 with the nodejs:24 module-stream RPM+# instead of node:24-alpine. The RPM Node dynamically links the system+# libcrypto.so.3, so node:crypto routes through RHEL's CMVP-validated OpenSSL+# FIPS provider (/usr/lib64/ossl-modules/fips.so). Upstream node images# statically bundle their own non-validated OpenSSL and bypass the platform# module entirely.-# The default is the public Alpine image, so the build needs no credentials.-# Iron Bank's Alpine compiles the FIPS provider from the validated source and-# serves it from an authenticated registry with DoD provenance and scan-# attestations. Release builds opt in after `docker login registry1.dso.mil`-# (free P1 account plus a CLI secret):-# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24-ARG BASE_IMAGE=alpine:3.24--# The FIPS provider plus its self-test record (fipsmodule.cnf) and the opt-in-# config that activates it. Iron Bank's Alpine already carries the provider; on-# any other base it is compiled here from the checksum-pinned OpenSSL 3.1.2-# source with the configure flags Iron Bank uses-# (repo1.dso.mil/dsop/opensource/alpinelinux/alpine), so both bases ship the-# same module. Only these files leave the stage; libcrypto and libssl stay-# Alpine's packages, which load the 3.1.2 provider like any other.-FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS fips-provider-RUN set -eux; \- if [ ! -f /usr/lib/ossl-modules/fips.so ]; then \- apk add --no-cache gcc linux-headers make musl-dev perl; \- wget -qO /tmp/openssl.tar.gz https://github.com/openssl/openssl/releases/download/openssl-3.1.2/openssl-3.1.2.tar.gz; \- echo "a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539 /tmp/openssl.tar.gz" | sha256sum -c -; \- mkdir /tmp/openssl; \- tar -xzf /tmp/openssl.tar.gz -C /tmp/openssl --strip-components=1; \- cd /tmp/openssl; \- perl ./Configure --prefix=/usr --libdir=lib --openssldir=/etc/ssl \- enable-ktls shared no-zlib no-async no-comp no-idea no-mdc2 no-rc5 \- no-ec2m no-sm2 no-sm4 no-ssl3 no-seed no-weak-ssl-ciphers enable-fips \- enable-ec_nistp_64_gcc_128 -Wa,--noexecstack; \- make -j"$(nproc)" build_sw; \- make install_sw install_fips; \- openssl fipsinstall -pedantic -out /etc/ssl/fipsmodule.cnf -module /usr/lib/ossl-modules/fips.so; \- fi; \- mkdir -p /out/usr/lib/ossl-modules /out/etc/ssl; \- cp /usr/lib/ossl-modules/fips.so /out/usr/lib/ossl-modules/fips.so; \- cp /etc/ssl/fipsmodule.cnf /out/etc/ssl/fipsmodule.cnf--# FIPS mode is opt-in, so installs without it keep OpenSSL's default policy:-# entrypoint.sh points OPENSSL_CONF here when LANGFUSE_REQUIRE_FIPS=true, and-# deployments that override the entrypoint set-# OPENSSL_CONF=/etc/ssl/openssl-fips.cnf themselves. Node reads the nodejs_conf-# section and every other OpenSSL user (e.g. the Prisma engines) openssl_conf,-# so both select it. Only the fips and base providers load, and fips=yes keeps-# every algorithm fetch on the validated module. With-# LANGFUSE_REQUIRE_FIPS=true, startup fails unless it is active and an-# enterprise license is configured.-COPY <<EOF /out/etc/ssl/openssl-fips.cnf-nodejs_conf = fips_init-openssl_conf = fips_init--.include /etc/ssl/fipsmodule.cnf--[fips_init]-providers = provider_sect-alg_section = algorithm_sect--[provider_sect]-fips = fips_sect-base = base_sect--[base_sect]-activate = 1--[algorithm_sect]-default_properties = fips=yes-EOF+# The defaults are Red Hat's public UBI9 images, so the build needs no+# credentials. Iron Bank serves the same content from an authenticated registry+# with DoD provenance and scan attestations. Release builds opt in by overriding+# both args after `docker login registry1.dso.mil` (free P1 account plus a CLI+# secret):+# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8+# --build-arg MICRO_BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8+ARG BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:9.8+ARG MICRO_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-micro:9.8FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS base-COPY --from=fips-provider /out/ /--# Iron Bank's Alpine activates the FIPS provider in the system openssl.cnf;-# restore the stock file so FIPS stays opt-in on either base (see-# fips-provider above).-# icu-data-full is required: Alpine's Node uses the system ICU, whose default-# data package only covers English, and V8 segfaults in Intl.Segmenter (used-# e.g. by the prisma CLI's output formatting) without the full ICU data.-RUN apk upgrade --no-cache && \- apk add --no-cache nodejs npm icu-data-full && \- cp /etc/ssl/openssl.cnf.dist /etc/ssl/openssl.cnf && \- rm -f /etc/ssl/*.apk-new+# nodejs:24 and openssl (incl. the FIPS provider) come from the freely+# redistributable UBI repos, so no RHEL entitlement is required.+# nodejs-full-i18n is required: the RPM Node is a small-ICU build and V8+# segfaults in Intl.Segmenter (used e.g. by the prisma CLI's output+# formatting) without the full ICU data.+RUN dnf -y upgrade && \+ dnf -y module enable nodejs:24 && \+ dnf -y install --setopt=install_weak_deps=0 nodejs npm nodejs-full-i18n && \+ dnf clean allFROM --platform=${TARGETPLATFORM:-linux/amd64} base AS build-base# Pin turbo to avoid nondeterministic prune output from future patch releases.@@ -93,29 +34,68 @@ RUN npm install -g [email protected] [email protected]# Pass --build-arg NODE_USE_ENV_PROXY=1 when building behind a proxy.ARG NODE_USE_ENV_PROXY-# The runtime image carries no package manager, python, or curl: apk-tools is-# removed after the install below, and its database stays for scanners.-FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS runtime-base+# Runtime rootfs assembled with dnf --installroot and layered onto ubi9-micro:+# the final image carries no package manager, python, or curl. It holds only+# the packages listed below plus their deps, with an intact rpmdb for scanners.+FROM --platform=${TARGETPLATFORM:-linux/amd64} base AS rpm-installer+ARG TARGETARCHARG UID=1001ARG GID=1001-COPY --from=fips-provider /out/ /--# icu-data-full: see the base stage. tzdata provides the zoneinfo for TZ.-# dumb-init preserves the semver-covered ENTRYPOINT contract. busybox (in the-# base) provides the shell and the sed used by entrypoint.sh, and its wget-# keeps exec-style container health checks working (e.g. `wget --spider-# http://127.0.0.1:<port>/...` in ECS task definitions). Probe 127.0.0.1, not-# localhost: busybox wget only tries the first address localhost resolves to,-# which is ::1, and the server listens on IPv4.-RUN apk upgrade --no-cache && \- apk add --no-cache nodejs icu-data-full tzdata ca-certificates dumb-init && \- cp /etc/ssl/openssl.cnf.dist /etc/ssl/openssl.cnf && \- rm -f /etc/ssl/*.apk-new && \- addgroup -S -g "${GID}" nodejs && \- adduser -S -D -H -u "${UID}" -G nodejs -h /home/nextjs -s /sbin/nologin nextjs && \- apk del --no-cache apk-tools+# nodejs-full-i18n is required: the RPM Node is a small-ICU build and V8+# segfaults in Intl.Segmenter (used e.g. by the prisma CLI's output+# formatting) without the full ICU data. sed is used by entrypoint.sh.+# wget keeps exec-style container health checks working (e.g. `wget --spider+# http://127.0.0.1:<port>/...` in ECS task definitions); it links GnuTLS,+# which follows the host's FIPS mode like OpenSSL does.+RUN dnf -y --installroot /mnt/rootfs --releasever 9 --setopt=install_weak_deps=0 \+ --disableexcludes=all \+ module enable nodejs:24 && \+ dnf -y --installroot /mnt/rootfs --releasever 9 \+ --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \+ --disableexcludes=all \+ install nodejs nodejs-full-i18n bash coreutils-single sed \+ tzdata ca-certificates crypto-policies wget && \+ dnf --installroot /mnt/rootfs clean all && \+ rm -rf /mnt/rootfs/var/cache /mnt/rootfs/var/log/dnf*++# The nodejs RPM drags npm in as a dependency; the runtime image must carry+# no package manager, so remove it from the rootfs (rpmdb stays consistent).+RUN if rpm --root /mnt/rootfs -q npm >/dev/null 2>&1; then \+ rpm --root /mnt/rootfs -e --nodeps npm; \+ fi++# The FIPS crypto policy for OpenSSL ships as an opt-in config instead of+# being activated system-wide, so installs without FIPS mode keep the default+# TLS policy. entrypoint.sh points OPENSSL_CONF at it when+# LANGFUSE_REQUIRE_FIPS=true; deployments that override the entrypoint set+# OPENSSL_CONF=/etc/pki/tls/openssl-fips.cnf themselves. The FIPS provider+# itself loads only when the host kernel runs in FIPS mode; with+# LANGFUSE_REQUIRE_FIPS=true, startup fails unless it is active and an+# enterprise license is configured.+RUN sed 's#/etc/crypto-policies/back-ends/opensslcnf.config#/usr/share/crypto-policies/FIPS/opensslcnf.txt#' \+ /mnt/rootfs/etc/pki/tls/openssl.cnf > /mnt/rootfs/etc/pki/tls/openssl-fips.cnf && \+ grep -q '/usr/share/crypto-policies/FIPS/opensslcnf.txt' /mnt/rootfs/etc/pki/tls/openssl-fips.cnf++# dumb-init is not packaged in UBI; install the pinned, checksum-verified+# static release binary (preserves the semver-covered ENTRYPOINT contract).+RUN set -eux; \+ case "${TARGETARCH:-amd64}" in \+ amd64) di_arch=x86_64; di_sha256=e874b55f3279ca41415d290c512a7ba9d08f98041b28ae7c2acb19a545f1c4df ;; \+ arm64) di_arch=aarch64; di_sha256=b7d648f97154a99c539b63c55979cd29f005f88430fb383007fe3458340b795e ;; \+ *) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \+ esac; \+ curl -fsSL -o /mnt/rootfs/usr/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_${di_arch}"; \+ echo "${di_sha256} /mnt/rootfs/usr/bin/dumb-init" | sha256sum -c -; \+ chmod 0755 /mnt/rootfs/usr/bin/dumb-init++# Bake the non-root user into the rootfs (micro has no shadow-utils).+RUN echo "nodejs:x:${GID}:" >> /mnt/rootfs/etc/group && \+ echo "nextjs:x:${UID}:${GID}::/home/nextjs:/sbin/nologin" >> /mnt/rootfs/etc/passwd++FROM --platform=${TARGETPLATFORM:-linux/amd64} ${MICRO_BASE_IMAGE} AS runtime-base+COPY --from=rpm-installer /mnt/rootfs /# prisma CLI + optional dd-trace are npm-installed here and copied into the# package-manager-less runtime image.@@ -272,7 +252,8 @@ ENV DOCKER_BUILD 0# Set NEXT_MANUAL_SIG_HANDLE for runtimeENV NEXT_MANUAL_SIG_HANDLE true-# The non-root user (nextjs, uid 1001) is created in the runtime-base stage.+# The non-root user (nextjs, uid 1001) is baked into the runtime rootfs by+# the rpm-installer stage, since micro has no shadow-utils.# prisma CLI from the tools stage (bin/prisma symlink + lib/node_modules# structure lands under /usr/local); the runtime image has no npm.diff --git a/web/entrypoint.sh b/web/entrypoint.shindex f1aa0e5f42..e2a3204b74 100644--- a/web/entrypoint.sh+++ b/web/entrypoint.sh@@ -1,14 +1,14 @@#!/bin/sh# Fail closed when FIPS mode is required but the OpenSSL FIPS provider is not-# active for Node (e.g. an OPENSSL_CONF that does not load it, or an image-# rebuilt on a base without the provider). This runs before the migrations-# below open database connections. The app additionally requires an enterprise-# license for FIPS mode at startup (packages/shared/src/server/ee/fips).+# active for Node (e.g. a host without FIPS mode, or an image rebuilt on a+# non-FIPS base). This runs before the migrations below open database+# connections. The app additionally requires an enterprise license for FIPS+# mode at startup (packages/shared/src/server/ee/fips).if [ "$LANGFUSE_REQUIRE_FIPS" = "true" ]; then- # Opt into the FIPS provider config for OpenSSL (see the Dockerfile). An+ # Opt into the FIPS crypto policy for OpenSSL (see the Dockerfile). An# OPENSSL_CONF set by the deployment takes precedence.- export OPENSSL_CONF="${OPENSSL_CONF:-/etc/ssl/openssl-fips.cnf}"+ export OPENSSL_CONF="${OPENSSL_CONF:-/etc/pki/tls/openssl-fips.cnf}"if ! node -e 'process.exit(require("node:crypto").getFips() === 1 ? 0 : 1)'; thenecho "Error: LANGFUSE_REQUIRE_FIPS=true but Node's OpenSSL FIPS provider is not active (crypto.getFips() != 1). Exiting..."exit 1diff --git a/web/src/server/utils/jwt.ts b/web/src/server/utils/jwt.tsindex e4a4284259..2ca2fc0aa0 100644--- a/web/src/server/utils/jwt.ts+++ b/web/src/server/utils/jwt.ts@@ -36,9 +36,8 @@ export type Es256JwtVerifier<TClaims extends JwtRegisteredClaims> = {// ES256 is ECDSA P-256 with SHA-256:// https://www.rfc-editor.org/rfc/rfc7518.html#section-3.4-// The OpenSSL 3.1.2 FIPS provider the images ship approves that combination-// in Table 5:-// https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4985.pdf+// RHEL 9's validated OpenSSL provider approves that combination in Table 6:+// https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4857.pdfconst Es256JwtHeaderSchema = z.object({alg: z.literal("ES256"),typ: z.literal("JWT"),diff --git a/worker/Dockerfile b/worker/Dockerfileindex 8949dcb182..c0a4d011b4 100644--- a/worker/Dockerfile+++ b/worker/Dockerfile@@ -1,89 +1,30 @@-# FIPS 140-3 base: Alpine with the distribution's nodejs package instead of-# node:24-alpine. Alpine's Node dynamically links the system libcrypto.so.3, so-# node:crypto routes through the OpenSSL 3.1.2 FIPS provider-# (/usr/lib/ossl-modules/fips.so, CMVP certificate #4985). Upstream node images+# FIPS 140-3 base: UBI 9 with the nodejs:24 module-stream RPM+# instead of node:24-alpine. The RPM Node dynamically links the system+# libcrypto.so.3, so node:crypto routes through RHEL's CMVP-validated OpenSSL+# FIPS provider (/usr/lib64/ossl-modules/fips.so). Upstream node images# statically bundle their own non-validated OpenSSL and bypass the platform# module entirely.-# The default is the public Alpine image, so the build needs no credentials.-# Iron Bank's Alpine compiles the FIPS provider from the validated source and-# serves it from an authenticated registry with DoD provenance and scan-# attestations. Release builds opt in after `docker login registry1.dso.mil`-# (free P1 account plus a CLI secret):-# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/opensource/alpinelinux/alpine:3.24-ARG BASE_IMAGE=alpine:3.24--# The FIPS provider plus its self-test record (fipsmodule.cnf) and the opt-in-# config that activates it. Iron Bank's Alpine already carries the provider; on-# any other base it is compiled here from the checksum-pinned OpenSSL 3.1.2-# source with the configure flags Iron Bank uses-# (repo1.dso.mil/dsop/opensource/alpinelinux/alpine), so both bases ship the-# same module. Only these files leave the stage; libcrypto and libssl stay-# Alpine's packages, which load the 3.1.2 provider like any other.-FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS fips-provider-RUN set -eux; \- if [ ! -f /usr/lib/ossl-modules/fips.so ]; then \- apk add --no-cache gcc linux-headers make musl-dev perl; \- wget -qO /tmp/openssl.tar.gz https://github.com/openssl/openssl/releases/download/openssl-3.1.2/openssl-3.1.2.tar.gz; \- echo "a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539 /tmp/openssl.tar.gz" | sha256sum -c -; \- mkdir /tmp/openssl; \- tar -xzf /tmp/openssl.tar.gz -C /tmp/openssl --strip-components=1; \- cd /tmp/openssl; \- perl ./Configure --prefix=/usr --libdir=lib --openssldir=/etc/ssl \- enable-ktls shared no-zlib no-async no-comp no-idea no-mdc2 no-rc5 \- no-ec2m no-sm2 no-sm4 no-ssl3 no-seed no-weak-ssl-ciphers enable-fips \- enable-ec_nistp_64_gcc_128 -Wa,--noexecstack; \- make -j"$(nproc)" build_sw; \- make install_sw install_fips; \- openssl fipsinstall -pedantic -out /etc/ssl/fipsmodule.cnf -module /usr/lib/ossl-modules/fips.so; \- fi; \- mkdir -p /out/usr/lib/ossl-modules /out/etc/ssl; \- cp /usr/lib/ossl-modules/fips.so /out/usr/lib/ossl-modules/fips.so; \- cp /etc/ssl/fipsmodule.cnf /out/etc/ssl/fipsmodule.cnf--# FIPS mode is opt-in, so installs without it keep OpenSSL's default policy:-# entrypoint.sh points OPENSSL_CONF here when LANGFUSE_REQUIRE_FIPS=true, and-# deployments that override the entrypoint set-# OPENSSL_CONF=/etc/ssl/openssl-fips.cnf themselves. Node reads the nodejs_conf-# section and every other OpenSSL user (e.g. the Prisma engines) openssl_conf,-# so both select it. Only the fips and base providers load, and fips=yes keeps-# every algorithm fetch on the validated module. With-# LANGFUSE_REQUIRE_FIPS=true, startup fails unless it is active and an-# enterprise license is configured.-COPY <<EOF /out/etc/ssl/openssl-fips.cnf-nodejs_conf = fips_init-openssl_conf = fips_init--.include /etc/ssl/fipsmodule.cnf--[fips_init]-providers = provider_sect-alg_section = algorithm_sect--[provider_sect]-fips = fips_sect-base = base_sect--[base_sect]-activate = 1--[algorithm_sect]-default_properties = fips=yes-EOF+# The defaults are Red Hat's public UBI9 images, so the build needs no+# credentials. Iron Bank serves the same content from an authenticated registry+# with DoD provenance and scan attestations. Release builds opt in by overriding+# both args after `docker login registry1.dso.mil` (free P1 account plus a CLI+# secret):+# --build-arg BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9:9.8+# --build-arg MICRO_BASE_IMAGE=registry1.dso.mil/ironbank/redhat/ubi/ubi9-micro:9.8+ARG BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:9.8+ARG MICRO_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-micro:9.8FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS base-COPY --from=fips-provider /out/ /--# Iron Bank's Alpine activates the FIPS provider in the system openssl.cnf;-# restore the stock file so FIPS stays opt-in on either base (see-# fips-provider above).-# icu-data-full is required: Alpine's Node uses the system ICU, whose default-# data package only covers English, and V8 segfaults in Intl.Segmenter (used-# e.g. by the prisma CLI's output formatting) without the full ICU data.-RUN apk upgrade --no-cache && \- apk add --no-cache nodejs npm icu-data-full && \- cp /etc/ssl/openssl.cnf.dist /etc/ssl/openssl.cnf && \- rm -f /etc/ssl/*.apk-new+# nodejs:24 and openssl (incl. the FIPS provider) come from the freely+# redistributable UBI repos, so no RHEL entitlement is required.+# nodejs-full-i18n is required: the RPM Node is a small-ICU build and V8+# segfaults in Intl.Segmenter (used e.g. by the prisma CLI's output+# formatting) without the full ICU data.+RUN dnf -y upgrade && \+ dnf -y module enable nodejs:24 && \+ dnf -y install --setopt=install_weak_deps=0 nodejs npm nodejs-full-i18n && \+ dnf clean allFROM --platform=${TARGETPLATFORM:-linux/amd64} base AS build-base# Pin turbo to avoid nondeterministic prune output from future patch releases.@@ -93,29 +34,68 @@ RUN npm install -g [email protected] [email protected]# Pass --build-arg NODE_USE_ENV_PROXY=1 when building behind a proxy.ARG NODE_USE_ENV_PROXY-# The runtime image carries no package manager, python, or curl: apk-tools is-# removed after the install below, and its database stays for scanners.-FROM --platform=${TARGETPLATFORM:-linux/amd64} ${BASE_IMAGE} AS runtime-base+# Runtime rootfs assembled with dnf --installroot and layered onto ubi9-micro:+# the final image carries no package manager, python, or curl. It holds only+# the packages listed below plus their deps, with an intact rpmdb for scanners.+FROM --platform=${TARGETPLATFORM:-linux/amd64} base AS rpm-installer+ARG TARGETARCHARG UID=1001ARG GID=1001-COPY --from=fips-provider /out/ /--# icu-data-full: see the base stage. tzdata provides the zoneinfo for TZ.-# dumb-init preserves the semver-covered ENTRYPOINT contract. busybox (in the-# base) provides the shell, and its wget keeps exec-style container health-# checks working (e.g. `wget --spider http://127.0.0.1:<port>/...` in ECS task-# definitions). Probe 127.0.0.1, not localhost: busybox wget only tries the-# first address localhost resolves to, which is ::1, and the server listens on-# IPv4.-RUN apk upgrade --no-cache && \- apk add --no-cache nodejs icu-data-full tzdata ca-certificates dumb-init && \- cp /etc/ssl/openssl.cnf.dist /etc/ssl/openssl.cnf && \- rm -f /etc/ssl/*.apk-new && \- addgroup -S -g "${GID}" expressjs && \- adduser -S -D -H -u "${UID}" -G expressjs -h /home/expressjs -s /sbin/nologin expressjs && \- apk del --no-cache apk-tools+# nodejs-full-i18n is required: the RPM Node is a small-ICU build and V8+# segfaults in Intl.Segmenter (used e.g. by the prisma CLI's output+# formatting) without the full ICU data.+# wget keeps exec-style container health checks working (e.g. `wget --spider+# http://127.0.0.1:<port>/...` in ECS task definitions); it links GnuTLS,+# which follows the host's FIPS mode like OpenSSL does.+RUN dnf -y --installroot /mnt/rootfs --releasever 9 --setopt=install_weak_deps=0 \+ --disableexcludes=all \+ module enable nodejs:24 && \+ dnf -y --installroot /mnt/rootfs --releasever 9 \+ --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \+ --disableexcludes=all \+ install nodejs nodejs-full-i18n bash coreutils-single sed \+ tzdata ca-certificates crypto-policies wget && \+ dnf --installroot /mnt/rootfs clean all && \+ rm -rf /mnt/rootfs/var/cache /mnt/rootfs/var/log/dnf*++# The nodejs RPM drags npm in as a dependency; the runtime image must carry+# no package manager, so remove it from the rootfs (rpmdb stays consistent).+RUN if rpm --root /mnt/rootfs -q npm >/dev/null 2>&1; then \+ rpm --root /mnt/rootfs -e --nodeps npm; \+ fi++# The FIPS crypto policy for OpenSSL ships as an opt-in config instead of+# being activated system-wide, so installs without FIPS mode keep the default+# TLS policy. entrypoint.sh points OPENSSL_CONF at it when+# LANGFUSE_REQUIRE_FIPS=true; deployments that override the entrypoint set+# OPENSSL_CONF=/etc/pki/tls/openssl-fips.cnf themselves. The FIPS provider+# itself loads only when the host kernel runs in FIPS mode; with+# LANGFUSE_REQUIRE_FIPS=true, startup fails unless it is active and an+# enterprise license is configured.+RUN sed 's#/etc/crypto-policies/back-ends/opensslcnf.config#/usr/share/crypto-policies/FIPS/opensslcnf.txt#' \+ /mnt/rootfs/etc/pki/tls/openssl.cnf > /mnt/rootfs/etc/pki/tls/openssl-fips.cnf && \+ grep -q '/usr/share/crypto-policies/FIPS/opensslcnf.txt' /mnt/rootfs/etc/pki/tls/openssl-fips.cnf++# dumb-init is not packaged in UBI; install the pinned, checksum-verified+# static release binary (preserves the semver-covered ENTRYPOINT contract).+RUN set -eux; \+ case "${TARGETARCH:-amd64}" in \+ amd64) di_arch=x86_64; di_sha256=e874b55f3279ca41415d290c512a7ba9d08f98041b28ae7c2acb19a545f1c4df ;; \+ arm64) di_arch=aarch64; di_sha256=b7d648f97154a99c539b63c55979cd29f005f88430fb383007fe3458340b795e ;; \+ *) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \+ esac; \+ curl -fsSL -o /mnt/rootfs/usr/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_${di_arch}"; \+ echo "${di_sha256} /mnt/rootfs/usr/bin/dumb-init" | sha256sum -c -; \+ chmod 0755 /mnt/rootfs/usr/bin/dumb-init++# Bake the non-root user into the rootfs (micro has no shadow-utils).+RUN echo "expressjs:x:${GID}:" >> /mnt/rootfs/etc/group && \+ echo "expressjs:x:${UID}:${GID}::/home/expressjs:/sbin/nologin" >> /mnt/rootfs/etc/passwd++FROM --platform=${TARGETPLATFORM:-linux/amd64} ${MICRO_BASE_IMAGE} AS runtime-base+COPY --from=rpm-installer /mnt/rootfs /FROM --platform=${TARGETPLATFORM:-linux/amd64} build-base AS pruner@@ -124,32 +104,29 @@ WORKDIR /appCOPY . .RUN turbo prune worker --docker-# Alpine build toolchain: Alpine's Node, pnpm, turbo, gcc and Rust. CI's-# tests-fips job also runs the web and worker test suites on this stage with-# OPENSSL_CONF=/etc/ssl/openssl-fips.cnf (scripts/ci/fips-tests.sh).+# UBI build toolchain: RPM Node, pnpm, turbo, gcc and Rust. CI's tests-fips job+# also runs the web and worker test suites on this stage with the OpenSSL FIPS+# provider forced on (scripts/ci/fips-tests.sh).FROM --platform=${TARGETPLATFORM:-linux/amd64} build-base AS toolchainARG TARGETARCH# @langfuse/native is a Rust addon (napi-rs) compiled by `turbo run build` for-# the musl (`*-unknown-linux-musl`) target, so it loads in the runtime image.-# gcc and musl-dev provide the linker and C runtime objects; bash runs the-# toolchain installer; curl and patch prepare the small clickhouse source-# overlay used by the native encoder. fips-tests.sh also needs bash and curl.-RUN apk add --no-cache gcc musl-dev bash curl patch--# rustc's musl targets default to a `<arch>-linux-musl-gcc` linker name that-# Alpine does not ship; its gcc is reachable as `cc`.-ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=cc CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=cc+# the glibc (`*-unknown-linux-gnu`) target, linked against UBI9's glibc so it+# loads in the runtime image. gcc provides the linker; tar and gzip unpack the+# pinned toolchain; patch (with the base image's curl-minimal) prepares the+# small clickhouse source overlay used by the native encoder.+RUN dnf -y install --setopt=install_weak_deps=0 gcc tar gzip patch && \+ dnf clean all# Pinned standalone Rust installer, the exact channel from# packages/native/rust-toolchain.toml (bump the two together), checksum-verified-# like the OpenSSL source above. Only rustc, cargo and the target's std are+# like the dumb-init binary above. Only rustc, cargo and the target's std are# needed to build; clippy and rustfmt run outside Docker.RUN set -eux; \case "${TARGETARCH:-amd64}" in \- amd64) triple=x86_64-unknown-linux-musl; toolchain_sha256=b2cf07e41d4747ddf3b20962ca9de2a08da00646f55ab4c1b51cef99895bae0a ;; \- arm64) triple=aarch64-unknown-linux-musl; toolchain_sha256=c26e37bb6f20e49498c552e53e3f34871ba2f7610c7f8b2cce38a48e3570c7de ;; \+ amd64) triple=x86_64-unknown-linux-gnu; toolchain_sha256=aa30409afa67bd1ada244cefd82c7980e6a65bc113bb978e934b2413c75e3900 ;; \+ arm64) triple=aarch64-unknown-linux-gnu; toolchain_sha256=5fbb4282403046d52a4672765c6761a809bf9f33e699b17e6eb7a93ab7770cc3 ;; \*) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \esac; \curl -fsSL -o /tmp/rust.tar.gz "https://static.rust-lang.org/dist/rust-1.98.0-${triple}.tar.gz"; \@@ -218,7 +195,8 @@ ENV BUILD_ID=$NEXT_PUBLIC_BUILD_IDENV NODE_ENV productionENV DOCKER_BUILD 0-# The non-root user (expressjs, uid 1001) is created in the runtime-base stage.+# The non-root user (expressjs, uid 1001) is baked into the runtime rootfs by+# the rpm-installer stage, since micro has no shadow-utils.# Copy only production worker payload instead of full builder workspace (just /prod/worker not entire /app)COPY --from=prod-deps --chown=expressjs:expressjs /prod/worker ./workerdiff --git a/worker/entrypoint.sh b/worker/entrypoint.shindex 86978b5d9c..081e8bcf41 100644--- a/worker/entrypoint.sh+++ b/worker/entrypoint.sh@@ -1,14 +1,14 @@#!/bin/sh# Fail closed when FIPS mode is required but the OpenSSL FIPS provider is not-# active for Node (e.g. an OPENSSL_CONF that does not load it, or an image-# rebuilt on a base without the provider). This runs before the migrations-# below open database connections. The app additionally requires an enterprise-# license for FIPS mode at startup (packages/shared/src/server/ee/fips).+# active for Node (e.g. a host without FIPS mode, or an image rebuilt on a+# non-FIPS base). This runs before the migrations below open database+# connections. The app additionally requires an enterprise license for FIPS+# mode at startup (packages/shared/src/server/ee/fips).if [ "$LANGFUSE_REQUIRE_FIPS" = "true" ]; then- # Opt into the FIPS provider config for OpenSSL (see the Dockerfile). An+ # Opt into the FIPS crypto policy for OpenSSL (see the Dockerfile). An# OPENSSL_CONF set by the deployment takes precedence.- export OPENSSL_CONF="${OPENSSL_CONF:-/etc/ssl/openssl-fips.cnf}"+ export OPENSSL_CONF="${OPENSSL_CONF:-/etc/pki/tls/openssl-fips.cnf}"if ! node -e 'process.exit(require("node:crypto").getFips() === 1 ? 0 : 1)'; thenecho "Error: LANGFUSE_REQUIRE_FIPS=true but Node's OpenSSL FIPS provider is not active (crypto.getFips() != 1). Exiting..."exit 1