mirror of https://github.com/vector-im/riot-web
Merge pull request #16698 from kvadevack/gzip-static
Docker image: serve pre-compressed assets using gzip_staticpull/16766/head
commit
8ad5640ece
|
@ -27,6 +27,11 @@ RUN cp /src/config.sample.json /src/webapp/config.json
|
||||||
# Ensure we populate the version file
|
# Ensure we populate the version file
|
||||||
RUN dos2unix /src/scripts/docker-write-version.sh && bash /src/scripts/docker-write-version.sh
|
RUN dos2unix /src/scripts/docker-write-version.sh && bash /src/scripts/docker-write-version.sh
|
||||||
|
|
||||||
|
# Pre-compress for gzip_static
|
||||||
|
RUN find /src/webapp -type f \
|
||||||
|
\( -iname '*.css' -o -iname '*.js' -o -iname '*.json' -o -iname '*.html' \
|
||||||
|
-o -iname '*.svg' -o -iname '*.ttf' -o -iname '*.wasm' \) \
|
||||||
|
-exec gzip -9 -k {} \; -exec touch -r {} {}.gz \;
|
||||||
|
|
||||||
# App
|
# App
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
@ -34,7 +39,8 @@ FROM nginx:alpine
|
||||||
COPY --from=builder /src/webapp /app
|
COPY --from=builder /src/webapp /app
|
||||||
|
|
||||||
# Insert wasm type into Nginx mime.types file so they load correctly.
|
# Insert wasm type into Nginx mime.types file so they load correctly.
|
||||||
RUN sed -i '3i\ \ \ \ application/wasm wasm\;' /etc/nginx/mime.types
|
RUN sed -i '3i\ \ \ \ application/wasm wasm\;' /etc/nginx/mime.types \
|
||||||
|
&& sed -i '2i\ gzip_static on\;' /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
RUN rm -rf /usr/share/nginx/html \
|
RUN rm -rf /usr/share/nginx/html \
|
||||||
&& ln -s /app /usr/share/nginx/html
|
&& ln -s /app /usr/share/nginx/html
|
||||||
|
|
Loading…
Reference in New Issue