29 lines
1.8 KiB
Bash
Executable File
29 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# R0 proof (D-R13): the browser module instantiates under the production CSP only with
|
|
# 'wasm-unsafe-eval'. Serves packages/core-wasm/pkg through the production nginx image with
|
|
# the DEPLOY.md header (as is, then with the keyword) and loads the page in headless Chromium.
|
|
#
|
|
# pnpm wasm:build
|
|
# CHROME=/path/to/chrome bash docker/csp-proof/run.sh # needs playwright-core on NODE_PATH
|
|
#
|
|
# Recorded result (2026-10-12, Chrome for Testing 156, nginx:1.31-alpine): docs/development/RUST.md §5.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/../.."
|
|
work="$(mktemp -d)"
|
|
mkdir -p "$work/site"
|
|
cp -r packages/core-wasm/pkg "$work/site/"
|
|
cp docker/csp-proof/site/index.html docker/csp-proof/site/main.js "$work/site/"
|
|
prod_csp="$(grep -m1 '^add_header Content-Security-Policy' DEPLOY.md | sed -E 's/^add_header Content-Security-Policy "(.*)" always;$/\1/')"
|
|
wasm_csp="${prod_csp/script-src \'self\'/script-src \'self\' \'wasm-unsafe-eval\'}"
|
|
for variant in without with; do
|
|
if [ "$variant" = without ]; then csp="$prod_csp"; else csp="$wasm_csp"; fi
|
|
sed "s/\${PORT}/8080/; s|^ # SPA fallback| add_header Content-Security-Policy \"$csp\" always;\n # SPA fallback|" docker/nginx.conf > "$work/csp-$variant.conf"
|
|
done
|
|
cleanup() { docker rm -f faunosteo_csp_without faunosteo_csp_with >/dev/null 2>&1 || true; }
|
|
trap cleanup EXIT
|
|
cleanup
|
|
docker run -d --rm --name faunosteo_csp_without -p 127.0.0.1:8091:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-without.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null
|
|
docker run -d --rm --name faunosteo_csp_with -p 127.0.0.1:8092:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-with.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null
|
|
sleep 1.5
|
|
node docker/csp-proof/run.mjs
|