diff --git a/Dockerfile b/Dockerfile index 808f234a3f57541a28dbdee2373bd597a6b943ad..e5b810dafa9e83d00e9a6d27a7e27f87d31e3cc5 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 c89ce8e2823326be25a61e3bce48205bf7982c61..b6fafd639132677bc063540002d277451f8cab25 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