From 678d41d75bcdf14b17fa13f69aa323a9f8716faa Mon Sep 17 00:00:00 2001 From: Dalf Date: Tue, 25 Feb 2020 17:25:11 +0100 Subject: [PATCH] [enh] Docker image: uwsgi serves the static files directly. When the image is built, the static files are compressed with gzip and brotli. The expires header is set to one day (same as Flask) There is not etag header (Flask does add an etag header) --- Dockerfile | 7 +++++-- dockerfiles/uwsgi.ini | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9885fb79..f61320bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,7 @@ RUN apk upgrade --no-cache \ tini \ uwsgi \ uwsgi-python3 \ + brotli \ && pip3 install --upgrade pip \ && pip3 install --no-cache -r requirements.txt \ && apk del build-dependencies @@ -61,8 +62,10 @@ RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \ touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \ if [ ! -z $VERSION_GITCOMMIT ]; then\ echo "VERSION_STRING = VERSION_STRING + \"-$VERSION_GITCOMMIT\"" >> /usr/local/searx/searx/version.py; \ - fi - + fi; \ + find /usr/local/searx/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \ + -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \ + -type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+ # Keep this argument at the end since it change each time ARG LABEL_DATE= diff --git a/dockerfiles/uwsgi.ini b/dockerfiles/uwsgi.ini index ecc4b394..398a440d 100644 --- a/dockerfiles/uwsgi.ini +++ b/dockerfiles/uwsgi.ini @@ -35,3 +35,10 @@ logto = /var/log/uwsgi/uwsgi.log # No keep alive # See https://github.com/searx/searx-docker/issues/24 add-header = Connection: close + +# uwsgi serves the static files +# expires set to one day as Flask does +static-map = /static=/usr/local/searx/searx/static +static-expires = /* 864000 +static-gzip-all = True +offload-threads = %k