-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ref: allow hosted js sdk bundles #3365
Merged
hubertdeng123
merged 19 commits into
getsentry:master
from
aldy505:ref/hosted-js-sdk-loader
Oct 7, 2024
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c4c3723
ref: allow hosted js sdk bundles
aldy505 a03e014
Update nginx/nginx.conf
aldy505 7284b7f
fix: provide default empty value for bash unbound variables
aldy505 61ef22e
ref: try without the external volume
aldy505 01eb641
test: js sdk assets
aldy505 b90dc77
chore: shfmt
aldy505 a7e0fa6
test: invoke dc-detect-version.sh script
aldy505 c1c1222
test: build web image first
aldy505 37a37ba
fix: sed on every ca-certificates related output
aldy505 eea547b
chore: more pointers or some kind of breakpoint
aldy505 47d1b9d
chore: commence the debug
aldy505 16bd556
fix: mounted the wrong directory
aldy505 ce9e4ca
test: debug out total directories
aldy505 5941c8e
test: try to ignore sdk_files tests
aldy505 aba6cea
test: re-enable sdk files
aldy505 7f90498
Update docker-compose.yml
aldy505 659b8ae
docs: tidy up js sdk loader docs
aldy505 338758d
chore: make SETUP_JS_SDK_ASSETS visible from .env file
aldy505 7bed4a8
Merge branch 'master' into ref/hosted-js-sdk-loader
aldy505 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
source _unit-test/_test_setup.sh | ||
source install/dc-detect-version.sh | ||
$dcb --force-rm web | ||
|
||
export SETUP_JS_SDK_ASSETS=1 | ||
|
||
source install/setup-js-sdk-assets.sh | ||
|
||
sdk_files=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx ls -lah /var/www/js-sdk/) | ||
sdk_tree=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx tree /var/www/js-sdk/ | tail -n 1) | ||
|
||
# `sdk_files` should contains 2 lines, `7.*` and `8.*` | ||
echo $sdk_files | ||
total_directories=$(echo "$sdk_files" | grep -c '[78]\.[0-9]*\.[0-9]*$') | ||
echo $total_directories | ||
test "2" == "$total_directories" | ||
echo "Pass" | ||
|
||
# `sdk_tree` should outputs "3 directories, 10 files" | ||
echo "$sdk_tree" | ||
test "2 directories, 10 files" == "$(echo "$sdk_tree")" | ||
echo "Pass" | ||
|
||
report_success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This will only run if the SETUP_JS_SDK_ASSETS environment variable is set to 1 | ||
if [[ "${SETUP_JS_SDK_ASSETS:-}" == "1" ]]; then | ||
echo "${_group}Setting up JS SDK assets" | ||
|
||
# If the `sentry-nginx-www` volume exists, we need to prune the contents. | ||
# We don't want to fill the volume with old JS SDK assets. | ||
# If people want to keep the old assets, they can set the environment variable | ||
# `SETUP_JS_SDK_KEEP_OLD_ASSETS` to any value. | ||
if [[ -z "${SETUP_JS_SDK_KEEP_OLD_ASSETS:-}" ]]; then | ||
echo "Cleaning up old JS SDK assets..." | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx rm -rf /var/www/js-sdk/* | ||
fi | ||
|
||
$dbuild -t sentry-self-hosted-jq-local --platform="$DOCKER_PLATFORM" jq | ||
|
||
jq="docker run --rm -i sentry-self-hosted-jq-local" | ||
|
||
loader_registry=$($dcr --no-deps --rm -T web cat /usr/src/sentry/src/sentry/loader/_registry.json) | ||
# The `loader_registry` should start with "Updating certificates...", we want to delete that and the subsequent ca-certificates related lines. | ||
# We want to remove everything before the first '{'. | ||
loader_registry=$(echo "$loader_registry" | sed '0,/{/s/[^{]*//') | ||
|
||
latest_js_v7=$(echo "$loader_registry" | $jq -r '.versions | reverse | map(select(.|any(.; startswith("7.")))) | .[0]') | ||
latest_js_v8=$(echo "$loader_registry" | $jq -r '.versions | reverse | map(select(.|any(.; startswith("8.")))) | .[0]') | ||
|
||
echo "Found JS SDKs v${latest_js_v7} and v${latest_js_v8}, downloading from upstream.." | ||
|
||
# Download those two using wget | ||
for version in "${latest_js_v7}" "${latest_js_v8}"; do | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx mkdir -p /var/www/js-sdk/${version} | ||
for variant in "tracing" "tracing.replay" "replay" "tracing.replay.feedback" "feedback"; do | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx wget -q -O /var/www/js-sdk/${version}/bundle.${variant}.min.js "https://browser.sentry-cdn.com/${version}/bundle.${variant}.min.js" | ||
done | ||
done | ||
|
||
echo "${_endgroup}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO if we're going to include this as part of the install script moving forwards, I'd like to see it in the
.env
file just to surface this as something people can set up. We can leave it as default for opt-inThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh not you too :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I read that wrong. Lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay done