🐳 fix: Qualify Docker Hub Image Names in Compose Files and Dockerfiles (#17950)

* fix: Qualify Docker Hub Image Names in Compose Files and Dockerfiles

Podman has no default registry, so a short image name such as mongo:8.0.20
or pgvector/pgvector:0.8.0-pg15-trixie fails with "short-name did not
resolve to an alias" unless the host configures unqualified-search
registries. Name docker.io on every third-party image in the compose files,
the override example and the Dockerfiles, using docker.io/library/ for
official images. Tags and digests are unchanged.

scripts/images.test.mjs fails on any image a compose file or Dockerfile
pulls without a registry host, and Static Checks runs it when one of those
files changes.

* test: Harden the image name scanner for indented comments and variable defaults

Commented image lines are matched at any indentation, a variable with an empty default or more than one interpolation is not guessed, and a Dockerfile FROM with a default is judged by that default, as in compose files.

* fix: Qualify the Channel Gateway and Mongo Replica Images

The channel compose stack landed on dev with short names, which the image name test now rejects.
This commit is contained in:
Marco Beretta 2026-11-14 21:47:59 +01:00 • committed by GitHub
parent 1da68ffa4c
commit effcec615d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 259 additions and 36 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 \

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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",

View file

@ -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

View file

@ -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

209
scripts/images.test.mjs Normal file
View file

@ -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',
);
});

View file

@ -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:

View file

@ -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