mirror of
https://github.com/searxng/searxng.git
synced 2025-08-10 22:06:44 +02:00
Building the container currently does not work properly. When rebuilding several times with `make container`, `version_frozen.py` is recreated, which wouldn't be an issue if the file’s timestamp was constant. Now, when creating `version_frozen.py`, it will have the same timestamp as the commit when it was created. (`version_frozen.py` is moved to a dedicated layer). Reusing "builder" cache when building "dist" could be slow (CD reports 2 seconds, but locally I've seen it take up to 10 seconds), so the Dockerfile is now split and we save a couple steps by importing the "builder" image directly. The last changes made it possible to remove the layer cache in "builder", since the overhead is now greater than building the layers from scratch. Until now, all "dist" layers were squashed into a single layer, which in most cases is a good idea (except for storage/delivery pricing/overhead), but in our case, since we manage the entire pipeline, we can ignore this and share layers between builds. This means (for example) that if we change files unrelated to the container in several consecutive commits (documentation changes), we don't have to push the entire image to registry, but only the different layers (`version_frozen.py` in this example). The same applies when pulling, as only the layers that have changed compared to the local layers will be downloaded (that's the theory, we'll see if this works as expected or if we need to tweak something else).
24 lines
800 B
Docker
24 lines
800 B
Docker
FROM ghcr.io/searxng/base:searxng-builder AS builder
|
|
|
|
COPY ./requirements*.txt ./
|
|
|
|
RUN --mount=type=cache,id=pip,target=/root/.cache/pip set -eux; \
|
|
python -m venv ./.venv/; \
|
|
. ./.venv/bin/activate; \
|
|
pip install -r ./requirements.txt -r ./requirements-server.txt
|
|
|
|
COPY ./searx/ ./searx/
|
|
|
|
ARG TIMESTAMP_SETTINGS="0"
|
|
|
|
RUN set -eux; \
|
|
python -m compileall -q ./searx/; \
|
|
touch -c --date=@$TIMESTAMP_SETTINGS ./searx/settings.yml; \
|
|
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 +; \
|
|
# Move always changing files to /usr/local/searxng/
|
|
mv ./searx/version_frozen.py ./
|