diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5a79006081..df967b099c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24.22.3-bookworm +FROM docker.io/library/node:24.22.3-bookworm RUN useradd -m -s /bin/bash vscode RUN mkdir -p /workspaces && chown -R vscode:vscode /workspaces diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 70ebf9b955..cdfa5427bb 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -41,14 +41,14 @@ services: - 27017 # ports: # - 27018:27017 - image: mongo + image: docker.io/library/mongo # restart: always volumes: - ./data-node:/data/db command: mongod --noauth meilisearch: container_name: chat-meilisearch - image: getmeili/meilisearch:v1.5 + image: docker.io/getmeili/meilisearch:v1.5 # restart: always expose: - 7700 diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 0c24dc55ac..4b7a803a2e 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -20,6 +20,13 @@ on: - '.github/workflows/static-checks.yml' - '.github/actions/mongodb-binary/**' - '.husky/pre-push' + # Compose files and Dockerfiles sit outside the source trees above, and + # the container image name test below has to run when one of them changes. + - '**/Dockerfile*' + - '**/*compose*.yml' + - '**/*compose*.yaml' + - '**/*compose*.yml.example' + - 'rag.yml' - '!**.md' # The merge queue tests the commit about to land on dev. It has no path filter; the checks # below stay scoped to what the queued change touches, read against the merge group base. @@ -218,6 +225,12 @@ jobs: if: steps.cache-node-modules.outputs.cache-hit == 'true' || steps.install_dependencies.outcome == 'success' run: npm run test:dependencies + # Podman has no default registry, so a short image name such as + # `mongo:8.0.20` fails to resolve for anyone running it with Podman. + - name: Test container image names + if: steps.cache-node-modules.outputs.cache-hit == 'true' || steps.install_dependencies.outcome == 'success' + run: npm run test:images + # The @shadcn/lint design rules read each primitive's `cva` variants through # the @librechat/client entry point, which resolves to packages/client/dist. # Without it they classify nothing and report strictly fewer violations than diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index d9b7b8163e..66f65b580e 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24.22.3-bookworm +FROM docker.io/library/node:24.22.3-bookworm ENV DEBIAN_FRONTEND=noninteractive \ SCARF_ANALYTICS=false \ diff --git a/Dockerfile b/Dockerfile index af301b392b..24bbf99286 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # v0.8.9-rc1 # Base node image -FROM node:24.22.3-alpine AS node +FROM docker.io/library/node:24.22.3-alpine AS node RUN apk upgrade --no-cache RUN apk add --no-cache bash jemalloc diff --git a/Dockerfile.multi b/Dockerfile.multi index fcc83a6871..d33b8f139a 100644 --- a/Dockerfile.multi +++ b/Dockerfile.multi @@ -10,7 +10,7 @@ ARG BUILD_BRANCH= ARG BUILD_DATE= # Base for all builds -FROM node:24.22.3-alpine AS base-min +FROM docker.io/library/node:24.22.3-alpine AS base-min ARG NPM_CI_TIMEOUT_SECONDS=1500 ARG NPM_CI_ATTEMPTS=2 RUN apk upgrade --no-cache diff --git a/deploy-compose.langfuse-fanout.yml b/deploy-compose.langfuse-fanout.yml index b4cf4424a1..32a9453760 100644 --- a/deploy-compose.langfuse-fanout.yml +++ b/deploy-compose.langfuse-fanout.yml @@ -41,7 +41,7 @@ services: - langfuse-fanout langfuse-fanout-redis: - image: redis:7.4-alpine + image: docker.io/library/redis:7.4-alpine restart: always expose: - '6379' @@ -49,7 +49,7 @@ services: - langfuse-fanout langfuse-fanout-otel: - image: otel/opentelemetry-collector-contrib:0.143.0 + image: docker.io/otel/opentelemetry-collector-contrib:0.143.0 restart: always command: ['--config=/etc/otelcol/otelcol.yaml'] env_file: diff --git a/deploy-compose.yml b/deploy-compose.yml index eac328a122..89125f287f 100644 --- a/deploy-compose.yml +++ b/deploy-compose.yml @@ -58,7 +58,7 @@ services: - SESSION_COOKIE_SECURE=${ADMIN_PANEL_SESSION_COOKIE_SECURE:-false} client: - image: nginx:1.27.0-alpine + image: docker.io/library/nginx:1.27.0-alpine container_name: LibreChat-NGINX ports: - 80:80 @@ -73,14 +73,14 @@ services: container_name: chat-mongodb # ports: # Uncomment this to access mongodb from outside docker, not safe in deployment # - 27018:27017 - image: mongo:8.0.20 + image: docker.io/library/mongo:8.0.20 restart: always volumes: - ./data-node:/data/db command: mongod --noauth meilisearch: container_name: chat-meilisearch - image: getmeili/meilisearch:v1.35.1 + image: docker.io/getmeili/meilisearch:v1.35.1 restart: always # ports: # Uncomment this to access meilisearch from outside docker # - 7700:7700 # if exposing these ports, make sure your master key is not the default value @@ -92,7 +92,7 @@ services: volumes: - ./meili_data_v1.35.1:/meili_data vectordb: - image: pgvector/pgvector:0.8.0-pg15-trixie + image: docker.io/pgvector/pgvector:0.8.0-pg15-trixie environment: POSTGRES_DB: mydatabase POSTGRES_USER: myuser diff --git a/docker-compose.langfuse-fanout.yml b/docker-compose.langfuse-fanout.yml index b4cf4424a1..32a9453760 100644 --- a/docker-compose.langfuse-fanout.yml +++ b/docker-compose.langfuse-fanout.yml @@ -41,7 +41,7 @@ services: - langfuse-fanout langfuse-fanout-redis: - image: redis:7.4-alpine + image: docker.io/library/redis:7.4-alpine restart: always expose: - '6379' @@ -49,7 +49,7 @@ services: - langfuse-fanout langfuse-fanout-otel: - image: otel/opentelemetry-collector-contrib:0.143.0 + image: docker.io/otel/opentelemetry-collector-contrib:0.143.0 restart: always command: ['--config=/etc/otelcol/otelcol.yaml'] env_file: diff --git a/docker-compose.mongo-replica.yml b/docker-compose.mongo-replica.yml index 3b7613777a..a6e80437ab 100644 --- a/docker-compose.mongo-replica.yml +++ b/docker-compose.mongo-replica.yml @@ -16,7 +16,7 @@ services: start_period: 10s retries: 12 mongodb-init: - image: mongo:8.0.20 + image: docker.io/library/mongo:8.0.20 restart: 'no' depends_on: mongodb: diff --git a/docker-compose.override.yml.example b/docker-compose.override.yml.example index 3b5159bf1c..19b48ae41e 100644 --- a/docker-compose.override.yml.example +++ b/docker-compose.override.yml.example @@ -62,7 +62,7 @@ # # ADD MONGO-EXPRESS # mongo-express: -# image: mongo-express +# image: docker.io/library/mongo-express # container_name: mongo-express # environment: # ME_CONFIG_MONGODB_SERVER: mongodb @@ -76,14 +76,14 @@ # # USE MONGODB V4.4.18 - FOR OLDER CPU WITHOUT AVX SUPPORT # mongodb: -# image: mongo:4.4.18 +# image: docker.io/library/mongo:4.4.18 # # DISABLE THE MONGODB CONTAINER - YOU NEED TO SET AN ALTERNATIVE MONGODB URI IN THE .ENV FILE # api: # environment: # - MONGO_URI=${MONGO_URI} # mongodb: -# image: tianon/true +# image: docker.io/tianon/true # command: "" # entrypoint: "" @@ -111,7 +111,7 @@ # # ADD OLLAMA # ollama: -# image: ollama/ollama:latest +# image: docker.io/ollama/ollama:latest # deploy: # resources: # reservations: @@ -144,7 +144,7 @@ # # ADD LITELLM CACHING # redis: -# image: redis:7-alpine +# image: docker.io/library/redis:7-alpine # command: # - sh # - -c # this is to evaluate the $REDIS_PASSWORD from the env @@ -171,7 +171,7 @@ # - NEXT_PUBLIC_SIGN_UP_DISABLED=${NEXT_PUBLIC_SIGN_UP_DISABLED:-false} # - LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false} # db: -# image: postgres +# image: docker.io/library/postgres # restart: always # environment: # - POSTGRES_USER=postgres diff --git a/docker-compose.yml b/docker-compose.yml index 2953a228ff..d16724907c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ services: - SESSION_COOKIE_SECURE=${ADMIN_PANEL_SESSION_COOKIE_SECURE:-false} mongodb: container_name: chat-mongodb - image: mongo:8.0.20 + image: docker.io/library/mongo:8.0.20 restart: always user: "${UID}:${GID}" volumes: @@ -63,7 +63,7 @@ services: command: mongod --noauth meilisearch: container_name: chat-meilisearch - image: getmeili/meilisearch:v1.35.1 + image: docker.io/getmeili/meilisearch:v1.35.1 restart: always user: "${UID}:${GID}" environment: @@ -74,7 +74,7 @@ services: - ./meili_data_v1.35.1:/meili_data vectordb: container_name: vectordb - image: pgvector/pgvector:0.8.0-pg15-trixie + image: docker.io/pgvector/pgvector:0.8.0-pg15-trixie environment: POSTGRES_DB: mydatabase POSTGRES_USER: myuser diff --git a/otel/langfuse-fanout/Dockerfile b/otel/langfuse-fanout/Dockerfile index c07d7eecfd..aa4be804ae 100644 --- a/otel/langfuse-fanout/Dockerfile +++ b/otel/langfuse-fanout/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.10-alpine3.24@sha256:a2012b4a1d1f9f7e9f44e0d39b805a901e856b1dd80b4e6ee4338db547050308 AS builder +FROM docker.io/library/golang:1.26.10-alpine3.24@sha256:a2012b4a1d1f9f7e9f44e0d39b805a901e856b1dd80b4e6ee4338db547050308 AS builder ENV GOTOOLCHAIN=local WORKDIR /src COPY otel/langfuse-fanout/go.mod otel/langfuse-fanout/go.sum* ./ @@ -6,7 +6,7 @@ RUN go mod download COPY otel/langfuse-fanout/ ./ RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/langfuse-fanout ./cmd/langfuse-fanout -FROM alpine:3.22 +FROM docker.io/library/alpine:3.22 RUN addgroup -S app && adduser -S app -G app COPY --from=builder /out/langfuse-fanout /usr/local/bin/langfuse-fanout USER app diff --git a/package.json b/package.json index 851ced48d1..52cd3eba64 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "test:packages:chat": "npm run build:data-provider && cd packages/chat && npm run test:ci", "test:config": "jest --config config/jest.config.js", "test:dependencies": "node --test scripts/dependencies.test.mjs", + "test:images": "node --test scripts/images.test.mjs", "test:all": "npm run test:client && npm run test:api && npm run test:packages:api && npm run test:packages:data-provider && npm run test:packages:data-schemas && npm run test:packages:chat", "test:turbo": "turbo run test:ci --concurrency=2", "e2e:update": "npm run e2e:prepare && playwright test --config=e2e/playwright.config.local.ts --update-snapshots", diff --git a/packages/channel-gateway/Dockerfile b/packages/channel-gateway/Dockerfile index f5de10c0c9..c2facc04fd 100644 --- a/packages/channel-gateway/Dockerfile +++ b/packages/channel-gateway/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24.22.3-alpine AS build +FROM docker.io/library/node:24.22.3-alpine AS build ENV SCARF_ANALYTICS=false HUSKY=0 WORKDIR /build @@ -22,7 +22,7 @@ RUN npm run build --workspace librechat-data-provider \ && npm run typecheck --workspace @librechat/channel-gateway \ && npm run build --workspace @librechat/channel-gateway -FROM node:24.22.3-alpine AS runtime +FROM docker.io/library/node:24.22.3-alpine AS runtime ENV NODE_ENV=production PORT=8080 LISTEN_HOST=0.0.0.0 WORKDIR /app diff --git a/rag.yml b/rag.yml index 0efe408a42..c075fd60fc 100644 --- a/rag.yml +++ b/rag.yml @@ -2,7 +2,7 @@ version: '3.8' services: vectordb: - image: pgvector/pgvector:0.8.0-pg15-trixie + image: docker.io/pgvector/pgvector:0.8.0-pg15-trixie environment: POSTGRES_DB: mydatabase POSTGRES_USER: myuser diff --git a/scripts/images.test.mjs b/scripts/images.test.mjs new file mode 100644 index 0000000000..61c5728d3c --- /dev/null +++ b/scripts/images.test.mjs @@ -0,0 +1,209 @@ +import { test } from 'node:test'; +import { basename } from 'node:path'; +import { readFileSync } from 'node:fs'; +import assert from 'node:assert/strict'; +import { fileURLToPath } from 'node:url'; +import { createRequire } from 'node:module'; +import { execFileSync } from 'node:child_process'; + +const root = fileURLToPath(new URL('..', import.meta.url)); +// js-yaml is a dependency of packages/api, not of the root manifest. +const { load } = createRequire(new URL('../packages/api/package.json', import.meta.url))('js-yaml'); + +/** + * Podman has no default registry, so a name without a registry host ("mongo:8.0.20", + * "pgvector/pgvector:0.8.0") is a short name and fails to resolve unless the host + * configures `unqualified-search-registries`. Docker applies the same host test and + * then falls back to Docker Hub, which is why only Podman users see the error. + */ +const hasRegistry = (ref) => /^([^/]*[.:][^/]*|localhost)\//.test(ref); + +/** The image Compose uses when `${VAR:-default}` is unset, or null when it cannot be known. */ +function resolve(value) { + const withDefault = /^\$\{\w+:?-([^}]*)\}$/.exec(value); + if (withDefault) return withDefault[1] || null; + return value.includes('$') ? null : value; +} + +/** Images a compose file pulls. A service with `build` only names the tag it builds. */ +function composeImages(text) { + const services = load(text)?.services ?? {}; + return Object.entries(services).flatMap(([name, service]) => { + const local = service?.build != null; + const ref = typeof service?.image === 'string' && !local ? resolve(service.image) : null; + return ref == null ? [] : [{ at: name, ref }]; + }); +} + +/** Commented-out `image:` lines, as in a template users copy from. A `build:` right after marks a local tag. */ +function commentedImages(text) { + const lines = text.split('\n'); + return lines.flatMap((line, i) => { + const match = /^(\s*#\s*)image:\s*(\S+)\s*$/.exec(line); + if (!match || lines[i + 1]?.startsWith(`${match[1]}build:`)) return []; + return [{ at: 'commented', ref: match[2].replace(/^["']|["']$/g, '') }]; + }); +} + +/** External images a Dockerfile pulls: FROM and COPY --from, minus stages, scratch and args without a default. */ +function dockerfileImages(text) { + const stages = new Set(); + const refs = []; + const pull = (at, raw) => { + const ref = resolve(raw); + const name = raw.toLowerCase(); + if (ref == null || stages.has(name) || name === 'scratch' || /^\d+$/.test(name)) return; + refs.push({ at, ref }); + }; + for (const line of text.split('\n')) { + const from = /^\s*FROM\s+(?:--\S+\s+)*(\S+)(?:\s+AS\s+(\S+))?/i.exec(line); + if (from) { + pull('FROM', from[1]); + if (from[2]) stages.add(from[2].toLowerCase()); + continue; + } + const copy = /^\s*COPY\s.*?--from=(\S+)/i.exec(line); + if (copy) pull('COPY --from', copy[1]); + } + return refs; +} + +test('hasRegistry applies the host rule Docker and Podman share', () => { + const qualified = [ + 'docker.io/library/mongo:8.0.20', + 'docker.io/pgvector/pgvector:0.8.0-pg15-trixie', + 'docker.io/library/golang:1.26.10-alpine3.24@sha256:abc', + 'registry.librechat.ai/librechat-ai/librechat:latest', + 'ghcr.io/astral-sh/uv:0.9.5', + 'localhost/librechat:local', + 'localhost:5000/librechat', + ]; + const short = [ + 'mongo', + 'mongo:8.0.20', + 'getmeili/meilisearch:v1.35.1', + 'pgvector/pgvector:0.8.0-pg15-trixie', + 'node:24.22.1-alpine', + ]; + for (const ref of qualified) assert.ok(hasRegistry(ref), ref); + for (const ref of short) assert.ok(!hasRegistry(ref), ref); +}); + +test('composeImages skips local builds and judges the default of an unset variable', () => { + const text = [ + 'services:', + ' db:', + ' image: mongo:8.0.20', + ' search:', + ' image: docker.io/getmeili/meilisearch:v1.35.1', + ' api:', + ' image: librechat:local', + ' build: .', + ' cache:', + ' image: ${CACHE_IMAGE:-redis:7-alpine}', + ' proxy:', + ' image: ${PROXY_IMAGE}', + ' empty:', + ' image: ${EMPTY_IMAGE:-}', + ' joined:', + ' image: ${HOST:-x}${NAME:-y}', + ' bare:', + ].join('\n'); + assert.deepEqual(composeImages(text), [ + { at: 'db', ref: 'mongo:8.0.20' }, + { at: 'search', ref: 'docker.io/getmeili/meilisearch:v1.35.1' }, + { at: 'cache', ref: 'redis:7-alpine' }, + ]); +}); + +test('commentedImages reads template snippets and exempts a local build tag', () => { + const text = [ + '# # ADD OLLAMA', + '# ollama:', + '# image: ollama/ollama:latest', + '', + '# # LOCAL BUILD', + '# api:', + '# image: librechat', + '# build:', + '# context: .', + '', + '# rag_api:', + '# image: "registry.librechat.ai/librechat-ai/librechat-rag-api-dev:latest"', + '', + 'services:', + ' db:', + ' # image: mongo:4.4.18', + ' image: docker.io/library/mongo:8.0.20', + ' api:', + ' # image: librechat', + ' # build: .', + ].join('\n'); + assert.deepEqual(commentedImages(text), [ + { at: 'commented', ref: 'ollama/ollama:latest' }, + { at: 'commented', ref: 'registry.librechat.ai/librechat-ai/librechat-rag-api-dev:latest' }, + { at: 'commented', ref: 'mongo:4.4.18' }, + ]); +}); + +test('dockerfileImages ignores stages, scratch, stage indexes and args without a default', () => { + const text = [ + 'FROM node:24-alpine AS base', + 'FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26 AS build', + 'FROM base AS dev', + 'FROM ${RUNTIME}', + 'FROM ${BASE:-alpine:3.22}', + 'FROM scratch', + 'COPY --from=base /a /b', + 'COPY --chown=1:1 --from=ghcr.io/astral-sh/uv:0.9 /uv /bin/uv', + 'COPY --from=pgvector/pgvector:0.8.0 /x /y', + 'COPY --from=0 /c /d', + '# FROM redis:7', + ].join('\n'); + assert.deepEqual(dockerfileImages(text), [ + { at: 'FROM', ref: 'node:24-alpine' }, + { at: 'FROM', ref: 'docker.io/library/golang:1.26' }, + { at: 'FROM', ref: 'alpine:3.22' }, + { at: 'COPY --from', ref: 'ghcr.io/astral-sh/uv:0.9' }, + { at: 'COPY --from', ref: 'pgvector/pgvector:0.8.0' }, + ]); +}); + +test('every image the repo pulls in a compose file or Dockerfile names its registry', () => { + const tracked = execFileSync('git', ['ls-files', '-z'], { + cwd: root, + encoding: 'utf8', + maxBuffer: 64 * 1024 * 1024, + }) + .split('\0') + .filter(Boolean); + const read = (file) => readFileSync(`${root}${file}`, 'utf8'); + + const dockerfiles = tracked.filter( + (file) => /(^|\/)(Docker|Container)file[^/]*$/.test(file) && !file.endsWith('.dockerignore'), + ); + const composeFiles = tracked + .filter((file) => /\.ya?ml(\.example)?$/.test(file)) + .filter((file) => /compose/i.test(basename(file)) || /^services:/m.test(read(file))); + assert.ok(dockerfiles.length > 0, 'found no Dockerfiles'); + assert.ok(composeFiles.length > 0, 'found no compose files'); + + const found = []; + for (const file of composeFiles) { + const text = read(file); + const live = /^services:/m.test(text) ? composeImages(text) : []; + for (const image of [...live, ...commentedImages(text)]) found.push({ file, ...image }); + } + for (const file of dockerfiles) { + for (const image of dockerfileImages(read(file))) found.push({ file, ...image }); + } + + const shortNames = found + .filter(({ ref }) => !hasRegistry(ref)) + .map(({ file, at, ref }) => `${file}: ${at}: ${ref}`); + assert.deepEqual( + shortNames, + [], + 'Podman cannot resolve these short names; add the registry host', + ); +}); diff --git a/search/compose.yml b/search/compose.yml index 64ec777cf7..51fed19e80 100644 --- a/search/compose.yml +++ b/search/compose.yml @@ -13,8 +13,8 @@ # original registry checks): # ghcr.io/ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0 # ghcr.io/ferretdb/ferretdb:2.7.0 -# pgvector/pgvector:0.8.6-pg17-trixie -# clickhouse/clickhouse-server:26.3.62.3 (26.3 LTS) +# docker.io/pgvector/pgvector:0.8.6-pg17-trixie +# docker.io/clickhouse/clickhouse-server:26.3.62.3 (26.3 LTS) # # Host ports are chosen to avoid every port used by docker-compose.yml, # deploy-compose.yml, rag.yml, utils/docker/test-compose.yml, @@ -86,7 +86,7 @@ services: # `vectordb` service used by rag_api file search (pinned pg15, superuser # bootstrap credential, live pgdata2 volume) - see PLAN.md decision 3. chat_search_db: - image: pgvector/pgvector:0.8.6-pg17-trixie + image: docker.io/pgvector/pgvector:0.8.6-pg17-trixie container_name: search-chat-search-db restart: on-failure environment: @@ -113,7 +113,7 @@ services: start_period: 10s clickhouse: - image: clickhouse/clickhouse-server:26.3.62.3 + image: docker.io/clickhouse/clickhouse-server:26.3.62.3 container_name: search-clickhouse restart: on-failure environment: diff --git a/utils/docker/test-compose.yml b/utils/docker/test-compose.yml index d6d0c23ee7..43baac1bca 100644 --- a/utils/docker/test-compose.yml +++ b/utils/docker/test-compose.yml @@ -23,14 +23,14 @@ services: container_name: chat-mongodb ports: # Uncomment this to access mongodb from outside docker, not safe in deployment - 27018:27017 - image: mongo + image: docker.io/library/mongo restart: always volumes: - ./data-node:/data/db command: mongod --noauth meilisearch: container_name: chat-meilisearch - image: getmeili/meilisearch:v1.7.3 + image: docker.io/getmeili/meilisearch:v1.7.3 ports: # Uncomment this to access meilisearch from outside docker - 7700:7700 # if exposing these ports, make sure your master key is not the default value env_file: @@ -41,7 +41,7 @@ services: volumes: - ./meili_data_v1.7:/meili_data vectordb: - image: pgvector/pgvector:0.8.0-pg15-trixie + image: docker.io/pgvector/pgvector:0.8.0-pg15-trixie environment: POSTGRES_DB: mydatabase POSTGRES_USER: myuser