From 7c5d02218bb99cc298c55b6602f197a880ce1a43 Mon Sep 17 00:00:00 2001 From: Bill Wallace Date: Sun, 8 Dec 2024 11:29:35 -0500 Subject: [PATCH] Precompressed NGINX build --- .docker/Viewer-v3.x/default.conf.template | 3 +++ .docker/compressDist.sh | 1 + Dockerfile | 10 ++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .docker/compressDist.sh diff --git a/.docker/Viewer-v3.x/default.conf.template b/.docker/Viewer-v3.x/default.conf.template index 11206da2a6..bbee324496 100644 --- a/.docker/Viewer-v3.x/default.conf.template +++ b/.docker/Viewer-v3.x/default.conf.template @@ -1,4 +1,7 @@ server { + gzip_static always; + gzip_proxied expired no-cache no-store private auth; + gunzip on; listen ${PORT} default_server; listen [::]:${PORT} default_server; location / { diff --git a/.docker/compressDist.sh b/.docker/compressDist.sh new file mode 100644 index 0000000000..168424f004 --- /dev/null +++ b/.docker/compressDist.sh @@ -0,0 +1 @@ +find platform/app/dist -name "*.js" -exec gzip -9 "{}" \; -exec touch "{}" \; diff --git a/Dockerfile b/Dockerfile index d7c19fdb65..6db0b3d29f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,7 @@ COPY --parents ./addOns/package.json ./addOns/*/*/package.json ./extensions/*/pa # Run the install before copying the rest of the files RUN yarn install # Copy the local directory -COPY --link --exclude=node_modules --exclude=yarn.lock --exclude=package.json . . +COPY --link --exclude=node_modules --exclude=yarn.lock --exclude=package.json --exclude=Dockerfile . . # Do a second install to finalize things after the copy RUN yarn install @@ -64,9 +64,15 @@ RUN yarn install # After install it should hopefully be stable until the local directory changes ENV QUICK_BUILD true # ENV GENERATE_SOURCEMAP=false -ENV REACT_APP_CONFIG=config/default.js +ARG REACT_APP_CONFIG=config/default.js +ARG PUBLIC_URL + RUN yarn run build +# Precompress files +RUN chmod u+x .docker/compressDist.sh +RUN ./.docker/compressDist.sh + # Stage 3: Bundle the built application into a Docker container # which runs Nginx using Alpine Linux FROM nginxinc/nginx-unprivileged:1.25-alpine as final