on master help sign in
[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)

commit678d41d75bcdf14b17fa13f69aa323a9f8716faa authorDalf <alex@al-f.net> dateTue 25 Feb 2020, 17:25 (7 years ago) parent6a3ef55
2 files changed+12−2
Dockerfile+5−2 dockerfiles/uwsgi.ini+7
Dockerfile+5−2
@@ -50,6 +50,7 @@ RUN apk upgrade --no-cache \
5050 tini \
5151 uwsgi \
5252 uwsgi-python3 \
53+ brotli \
5354 && pip3 install --upgrade pip \
5455 && pip3 install --no-cache -r requirements.txt \
5556 && apk del build-dependencies
@@ -61,8 +62,10 @@ RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
6162 touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
6263 if [ ! -z $VERSION_GITCOMMIT ]; then\
6364 echo "VERSION_STRING = VERSION_STRING + \"-$VERSION_GITCOMMIT\"" >> /usr/local/searx/searx/version.py; \
64− fi
65−
65+ fi; \
66+ find /usr/local/searx/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \
67+ -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
68+ -type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+
6669
6770# Keep this argument at the end since it change each time
6871ARG LABEL_DATE=
dockerfiles/uwsgi.ini+7
@@ -35,3 +35,10 @@ logto = /var/log/uwsgi/uwsgi.log
3535# No keep alive
3636# See https://github.com/searx/searx-docker/issues/24
3737add-header = Connection: close
38+
39+# uwsgi serves the static files
40+# expires set to one day as Flask does
41+static-map = /static=/usr/local/searx/searx/static
42+static-expires = /* 864000
43+static-gzip-all = True
44+offload-threads = %k