diff --git a/container/.env.example b/container/.env.example new file mode 100644 index 000000000..de2d1dd62 --- /dev/null +++ b/container/.env.example @@ -0,0 +1,15 @@ +# Read the documentation before using the `docker-compose.yml` file: +# https://docs.searxng.org/admin/installation-docker.html +# +# Additional ENVs: +# https://docs.searxng.org/admin/settings/settings_general.html#settings-general +# https://docs.searxng.org/admin/settings/settings_server.html#settings-server + +# Use a specific version tag. E.g. "latest" or "2026.3.25-541c6c3cb". +#SEARXNG_VERSION=latest + +# Listen to a specific address. +#SEARXNG_HOST=[::] + +# Listen to a specific port. +#SEARXNG_PORT=8080 diff --git a/container/dist.dockerfile b/container/dist.dockerfile index f2d4b0fee..b8af66f35 100644 --- a/container/dist.dockerfile +++ b/container/dist.dockerfile @@ -15,17 +15,17 @@ ARG VCS_URL="unknown" ARG VCS_REVISION="unknown" LABEL org.opencontainers.image.created="$CREATED" \ - org.opencontainers.image.description="SearXNG is a metasearch engine. Users are neither tracked nor profiled." \ - org.opencontainers.image.documentation="https://docs.searxng.org/admin/installation-docker" \ - org.opencontainers.image.licenses="AGPL-3.0-or-later" \ - org.opencontainers.image.revision="$VCS_REVISION" \ - org.opencontainers.image.source="$VCS_URL" \ - org.opencontainers.image.title="SearXNG" \ - org.opencontainers.image.url="https://searxng.org" \ - org.opencontainers.image.version="$VERSION" + org.opencontainers.image.description="SearXNG is a metasearch engine. Users are neither tracked nor profiled." \ + org.opencontainers.image.documentation="https://docs.searxng.org/admin/installation-docker" \ + org.opencontainers.image.licenses="AGPL-3.0-or-later" \ + org.opencontainers.image.revision="$VCS_REVISION" \ + org.opencontainers.image.source="$VCS_URL" \ + org.opencontainers.image.title="SearXNG" \ + org.opencontainers.image.url="https://searxng.org" \ + org.opencontainers.image.version="$VERSION" -ENV SEARXNG_VERSION="$VERSION" \ - SEARXNG_SETTINGS_PATH="$CONFIG_PATH/settings.yml" \ +ENV __SEARXNG_VERSION="$VERSION" \ + __SEARXNG_SETTINGS_PATH="$__SEARXNG_CONFIG_PATH/settings.yml" \ GRANIAN_PROCESS_NAME="searxng" \ GRANIAN_INTERFACE="wsgi" \ GRANIAN_HOST="::" \ @@ -36,8 +36,8 @@ ENV SEARXNG_VERSION="$VERSION" \ GRANIAN_BLOCKING_THREADS_IDLE_TIMEOUT="5m" # "*_PATH" ENVs are defined in base images -VOLUME $CONFIG_PATH -VOLUME $DATA_PATH +VOLUME $__SEARXNG_CONFIG_PATH +VOLUME $__SEARXNG_DATA_PATH EXPOSE 8080 diff --git a/container/docker-compose.yml b/container/docker-compose.yml new file mode 100644 index 000000000..d2d53e869 --- /dev/null +++ b/container/docker-compose.yml @@ -0,0 +1,28 @@ +# Read the documentation before using the `docker-compose.yml` file: +# https://docs.searxng.org/admin/installation-docker.html + +name: searxng + +services: + core: + container_name: searxng-core + image: docker.io/searxng/searxng:${SEARXNG_VERSION:-latest} + restart: always + ports: + - ${SEARXNG_HOST:+${SEARXNG_HOST}:}${SEARXNG_PORT:-8080}:${SEARXNG_PORT:-8080} + env_file: ./.env + volumes: + - ./core-config/:/etc/searxng/:Z + - core-data:/var/cache/searxng/ + + valkey: + container_name: searxng-valkey + image: docker.io/valkey/valkey:9-alpine + command: valkey-server --save 30 1 --loglevel warning + restart: always + volumes: + - valkey-data:/data/ + +volumes: + core-data: + valkey-data: diff --git a/container/entrypoint.sh b/container/entrypoint.sh index 10844f115..d33748bed 100755 --- a/container/entrypoint.sh +++ b/container/entrypoint.sh @@ -117,16 +117,22 @@ EOF } cat <8080/tcp + searxng-valkey ... ... 3 minutes ago Up 3 minutes 6379/tcp + +Print a service container logs: + +.. code:: sh + + $ docker compose logs -f core + +Access a service container shell (troubleshooting): + +.. code:: sh + + $ docker compose exec -it --user root core /bin/sh -l + /usr/local/searxng # + +Stop and remove the services: + +.. code:: sh + + $ docker compose down + +.. _Container manual instancing: + +Manual instancing +================= This section is intended for advanced users who need custom deployments. We -recommend using `Docker compose`_, which provides a preconfigured environment -with sensible defaults. +recommend using `Container compose instancing`_, which provides a preconfigured +environment with sensible defaults. Basic container instancing example: @@ -121,12 +202,18 @@ List running containers: CONTAINER ID IMAGE ... CREATED PORTS NAMES 1af574997e63 ... ... 3 minutes ago 0.0.0.0:8888->8080/tcp searxng +Print the container logs: + +.. code:: sh + + $ docker container logs -f searxng + Access the container shell (troubleshooting): .. code:: sh $ docker container exec -it --user root searxng /bin/sh -l - 1af574997e63:/usr/local/searxng# + /usr/local/searxng # Stop and remove the container: @@ -153,18 +240,12 @@ Environment variables The following environment variables can be configured: - ``$SEARXNG_*``: Controls the SearXNG configuration options, look out for - environment ``$SEARXNG_*`` in :ref:`settings server` and :ref:`settings - general`. + environment ``$SEARXNG_*`` in :ref:`settings server`, :ref:`settings + general` and the :origin:`container/.env.example` template. - ``$GRANIAN_*``: Controls the :ref:`Granian server options `. - ``$FORCE_OWNERSHIP``: Ensures mounted volumes/files are owned by the ``searxng:searxng`` user (default: ``true``) -Container internal paths (don't modify unless you know what you're doing): - -- ``$CONFIG_PATH``: Path to the SearXNG configuration directory (default: ``/etc/searxng``) -- ``$SEARXNG_SETTINGS_PATH``: Path to the SearXNG settings file (default: ``$CONFIG_PATH/settings.yml``) -- ``$DATA_PATH``: Path to the SearXNG data directory (default: ``/var/cache/searxng``) - .. _Container custom certificates: Custom certificates @@ -176,6 +257,8 @@ additional certificates as needed. They will be available on container (re)start or when running ``update-ca-certificates`` in the container shell. +This requires the container to be running with ``root`` privileges. + .. _Container custom images: Custom images @@ -199,3 +282,57 @@ container images are not officially supported): localhost/searxng/searxng builder ... About a minute ago 524 MB ghcr.io/searxng/base searxng-builder ... 2 days ago 378 MB ghcr.io/searxng/base searxng ... 2 days ago 42.2 MB + +Migrate from ``searxng-docker`` +=============================== + +We expect the following source directory structure: + +.. code:: sh + + . + └── searxng-docker + ├── searxng + │ ├── favicons.toml + │ ├── limiter.toml + │ ├── settings.yml + │ └── ... + ├── .env + ├── Caddyfile + ├── docker-compose.yml + └── ... + +Create a brand new environment outside ``searxng-docker`` directory, following +`Container compose instancing setup`_. + +Once up and running, stop the services and move the configuration files from +the old mount to the new one: + +.. code:: sh + + $ mv ./searxng-docker/searxng/* ./searxng/core-config/ + +If you have any custom environment variables in the old ``.env`` file, make +sure to add them manually to the new one. + +Consider setting up a reverse proxy if exposing the instance to the public. + +You should end with the following directory structure: + +.. code:: sh + + . + ├── searxng + │ ├── core-config + │ │ ├── favicons.toml + │ │ ├── limiter.toml + │ │ ├── settings.yml + │ │ └── ... + │ ├── .env.example + │ ├── .env + │ └── docker-compose.yml + └── searxng-docker + └── ... + +If everything is working on the new environment, you can remove the old +``searxng-docker`` directory and its contents.