Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image: serve pre-compressed assets using gzip_static #16698

Merged
merged 1 commit into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ RUN cp /src/config.sample.json /src/webapp/config.json
# Ensure we populate the version file
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
FROM nginx:alpine

COPY --from=builder /src/webapp /app

# 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 \
&& ln -s /app /usr/share/nginx/html