From fd6d92f6d379966573facfc42ffa600eb779d0fa Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Wed, 19 Feb 2025 10:58:58 -0700
Subject: [PATCH] add designmap

---
 Dockerfile             |  7 ++++++-
 hooks/01-nginx-hook.sh | 29 +++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 808f234a3..e5b810daf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,7 +18,7 @@ FROM ${BUILD_IMAGE} as buildenv
 
 # Whether to use the existing dist directory
 # Use for quick builds and CI/CD
-ARG USE_DIST=true
+ARG USE_DIST=false
 
 ENV CYPRESS_DOWNLOAD_USE_CA=1
 ENV npm_config_cafile=${SSL_CERT_FILE}
@@ -59,4 +59,9 @@ COPY --from=buildenv \
   /app/dist/nshmp-ws/browser/ \
   ${DOCUMENT_ROOT}/ws/nshmp
 
+COPY --from=buildenv \
+  --chown=usgs-user:usgs-user \
+  /app/dist/nshmp-designmaps/browser/ \
+  ${DOCUMENT_ROOT}/ws/designmaps
+
 WORKDIR /usr/share/nginx
diff --git a/hooks/01-nginx-hook.sh b/hooks/01-nginx-hook.sh
index c89ce8e28..b6fafd639 100755
--- a/hooks/01-nginx-hook.sh
+++ b/hooks/01-nginx-hook.sh
@@ -23,7 +23,7 @@ location /nshmp {
   try_files \$uri \$uri/ \$uri.html \$uri/index.html @nshmp-angular-fallback;
 }
 
-location  @nshmp-angular-fallback {
+location @nshmp-angular-fallback {
   rewrite  ^(.*)\$  /nshmp/index.html last;
 }
 EOF
@@ -48,7 +48,32 @@ location /ws/nshmp {
   try_files \$uri \$uri/ \$uri.html \$uri/index.html @swagger-angular-fallback;
 }
 
-location  @swagger-angular-fallback {
+location @swagger-angular-fallback {
   rewrite  ^(.*)\$  /ws/nshmp/index.html last;
 }
 EOF
+
+cat << EOF > "${NGINX_CONF_DIR}/02-server.conf"
+location /ws/designmaps {
+  add_header 'X-Frame-Options' 'DENY';
+  add_header 'X-Content-Type-Options' 'nosniff';
+  add_header 'Cache-Control' 'public';
+  add_header 'Access-Control-Allow-Origin' '*';
+  add_header 'Access-Control-Allow-Methods' '*';
+  add_header 'Access-Control-Allow-Headers' '*';
+
+  expires 5m;
+
+  # css/js are hash-stamped, and url will change if content changes
+  location ~* /ws/designmaps/(.*)\\.(css|js)\$ {
+    expires 1y;
+    try_files \$uri /ws/designmaps/previous/\$1.\$2;
+  }
+
+  try_files \$uri \$uri/ \$uri.html \$uri/index.html @designmaps-angular-fallback;
+}
+
+location @designmaps-angular-fallback {
+  rewrite  ^(.*)\$  /ws/designmaps/index.html last;
+}
+EOF
-- 
GitLab