From 222bf37bdae2b1ff5ee1db63a7c386c5782c8c36 Mon Sep 17 00:00:00 2001 From: Yann Odeyer Date: Sun, 24 Feb 2019 10:55:36 +0100 Subject: [PATCH] gzip static files in docker image --- Dockerfile | 2 ++ docker/nginx.conf | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 39ee8e2b927..f1b08544c70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ COPY ./dist/* /usr/share/nginx/html/ COPY ./docker/run.sh /usr/share/nginx/ COPY ./docker/configurator /usr/share/nginx/configurator +RUN find /usr/share/nginx/html/ -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \; + RUN chmod +x /usr/share/nginx/run.sh EXPOSE 8080 diff --git a/docker/nginx.conf b/docker/nginx.conf index e0bba3415b6..d66d04144eb 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -12,6 +12,13 @@ http { keepalive_timeout 65; + gzip on; + gzip_static on; + gzip_disable "msie6"; + + gzip_vary on; + gzip_types text/plain text/css application/javascript; + map $request_method $access_control_max_age { OPTIONS 1728000; # 20 days }