on master help sign in
Merge pull request #1865 from dalf/uwsgi_static

[enh] Docker image: uwsgi serves the static files directly.

commit4cc8644ec918461371f61007bc0e50e44620fc69 authorAlexandre Flament <alex@al-f.net> dateSat 19 Sep 2020, 16:04 (6 years ago) parent375cbd1dc8d975
2 files changed+12−2
Dockerfile+5−2 dockerfiles/uwsgi.ini+7
Dockerfile+5−2
@@ -52,6 +52,7 @@ RUN apk upgrade --no-cache \
5252 tini \
5353 uwsgi \
5454 uwsgi-python3 \
55+ brotli \
5556 && pip3 install --upgrade pip \
5657 && pip3 install --no-cache -r requirements.txt \
5758 && apk del build-dependencies \
@@ -64,8 +65,10 @@ RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
6465 touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
6566 if [ ! -z $VERSION_GITCOMMIT ]; then\
6667 echo "VERSION_STRING = VERSION_STRING + \"-$VERSION_GITCOMMIT\"" >> /usr/local/searx/searx/version.py; \
67− fi
68−
68+ fi; \
69+ find /usr/local/searx/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \
70+ -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
71+ -type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+
6972
7073# Keep this argument at the end since it change each time
7174ARG 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