[enh] container: merge dockerfiles (#6861)

* [enh] container: merge dockerfiles

Leftover from https://github.com/searxng/searxng/pull/6720

* [enh] apply suggestion

https://github.com/searxng/searxng/pull/6861#discussion_r4302473383
This commit is contained in:
Ivan Gabaldon authored and GitHub committed 2026-10-17 20:30:09 +02:00
1 parent 2a6fc07be3
commit 3afd949268
4 files changed
+36 -44

No files matched your search

@@ -1,4 +1,29 @@
FROM localhost/searxng/searxng:builder AS builder
FROM docker.io/searxng/base:searxng-builder AS builder
COPY ./requirements.txt ./requirements-server.txt ./
ENV UV_NO_MANAGED_PYTHON="true"
RUN --mount=type=cache,id=uv,target=/root/.cache/uv set -eux -o pipefail; \
uv venv; \
uv pip install --requirements ./requirements.txt --requirements ./requirements-server.txt; \
uv cache prune --ci; \
find ./.venv/lib/ -type f -exec strip --strip-unneeded {} + || true; \
find ./.venv/lib/ -type d -name "__pycache__" -exec rm -rf {} +; \
find ./.venv/lib/ -type f -name "*.pyc" -delete; \
python -m compileall -q -f -j 0 --invalidation-mode=unchecked-hash ./.venv/lib/
COPY --exclude=./searx/version_frozen.py ./searx/ ./searx/
RUN set -eux -o pipefail; \
python -m compileall -q -f -j 0 --invalidation-mode=unchecked-hash ./searx/; \
find ./searx/static/ -type f \
\( -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.svg" \) \
-exec gzip -9 -k {} + \
-exec brotli -9 -k {} + \
-exec gzip --test {}.gz + \
-exec brotli --test {}.br +
FROM docker.io/searxng/base:searxng AS dist
COPY --chown=977:977 --from=builder /usr/local/searxng/.venv/ ./.venv/
@@ -21,6 +46,8 @@ LABEL org.opencontainers.image.created="$CREATED" \
org.opencontainers.image.url="https://searxng.org" \
org.opencontainers.image.version="$VERSION"
# Extended from:
# https://codeberg.org/searxng/base/src/branch/main/Dockerfile
ENV __SEARXNG_VERSION="$VERSION" \
__SEARXNG_SETTINGS_PATH="$__SEARXNG_CONFIG_PATH/settings.yml" \
GRANIAN_PROCESS_NAME="searxng" \
@@ -32,7 +59,6 @@ ENV __SEARXNG_VERSION="$VERSION" \
GRANIAN_WORKERS_KILL_TIMEOUT="30s" \
GRANIAN_BLOCKING_THREADS_IDLE_TIMEOUT="5m"
# "*_PATH" ENVs are defined in base images
VOLUME $__SEARXNG_CONFIG_PATH
VOLUME $__SEARXNG_DATA_PATH
-25
View File
@@ -1,25 +0,0 @@
FROM docker.io/searxng/base:searxng-builder AS builder
COPY ./requirements.txt ./requirements-server.txt ./
ENV UV_NO_MANAGED_PYTHON="true"
RUN --mount=type=cache,id=uv,target=/root/.cache/uv set -eux -o pipefail; \
uv venv; \
uv pip install --requirements ./requirements.txt --requirements ./requirements-server.txt; \
uv cache prune --ci; \
find ./.venv/lib/ -type f -exec strip --strip-unneeded {} + || true; \
find ./.venv/lib/ -type d -name "__pycache__" -exec rm -rf {} +; \
find ./.venv/lib/ -type f -name "*.pyc" -delete; \
python -m compileall -q -f -j 0 --invalidation-mode=unchecked-hash ./.venv/lib/
COPY --exclude=./searx/version_frozen.py ./searx/ ./searx/
RUN set -eux -o pipefail; \
python -m compileall -q -f -j 0 --invalidation-mode=unchecked-hash ./searx/; \
find ./searx/static/ -type f \
\( -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.svg" \) \
-exec gzip -9 -k {} + \
-exec brotli -9 -k {} + \
-exec gzip --test {}.gz + \
-exec brotli --test {}.br +
+6 -6
View File
@@ -283,12 +283,12 @@ container images are not officially supported):
$ make container
$ docker images
REPOSITORY TAG IMAGE ID SIZE
localhost/searxng/searxng 2026.6.19-93f66bfb4 ... 265 MB
localhost/searxng/searxng latest ... 265 MB
localhost/searxng/searxng builder ... 687 MB
docker.io/searxng/base searxng-builder ... 565 MB
docker.io/searxng/base searxng ... 143 MB
REPOSITORY TAG IMAGE ID SIZE
localhost/searxng/searxng latest ... 271 MB
localhost/searxng/searxng 2026.10.17-* ... 271 MB
<none> <none> ... 677 MB
docker.io/searxng/base searxng ... 144 MB
docker.io/searxng/base searxng-builder ... 550 MB
Migrate from ``searxng-docker``
===============================
+2 -11
View File
@@ -126,11 +126,9 @@ container.build() {
info_msg "Set \$GIT_URL: $GIT_URL"
if [ "$container_engine" = "podman" ]; then
params_build_builder="build --format=oci --layers --platform=$platform --identity-label=false"
params_build="build --format=oci --layers --platform=$platform --identity-label=false"
else
params_build_builder="build --platform=$platform"
params_build=$params_build_builder
params_build="build --platform=$platform"
fi
local_tag_arch="localhost/searxng/searxng:$DOCKER_TAG-$arch$variant"
@@ -140,20 +138,13 @@ container.build() {
params_build+=" --tag=localhost/searxng/searxng:$DOCKER_TAG"
fi
# shellcheck disable=SC2086
"$container_engine" $params_build_builder \
--tag="localhost/searxng/searxng:builder" \
--file="./container/builder.dockerfile" \
.
build_msg CONTAINER "Image \"builder\" built"
# shellcheck disable=SC2086
"$container_engine" $params_build \
--build-arg="CREATED=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--build-arg="VERSION=$DOCKER_TAG" \
--build-arg="VCS_URL=$GIT_URL" \
--build-arg="VCS_REVISION=$(git rev-parse HEAD)" \
--file="./container/dist.dockerfile" \
--file="./container/Dockerfile" \
.
build_msg CONTAINER "Image built"