|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Installs mise system-wide and pre-installs the sentry-ruby toolchain (Java, |
| 4 | +# Ruby, Node) plus a headless Chromium, all baked into the image so the |
| 5 | +# container starts without downloading anything at runtime. |
| 6 | +# |
| 7 | +set -euo pipefail |
| 8 | + |
| 9 | +RUBY_VERSION="${RUBYVERSION:-latest}" |
| 10 | +USERNAME="${_REMOTE_USER:-sentry}" |
| 11 | +USER_HOME="${_REMOTE_USER_HOME:-/home/${USERNAME}}" |
| 12 | + |
| 13 | +# Install mise system-wide via the official installer. This downloads a prebuilt |
| 14 | +# binary from mise's CDN rather than the GitHub API, avoiding the API rate |
| 15 | +# limits the gh-release-based community feature hits on shared CI runners. |
| 16 | +echo "📦 Installing mise..." |
| 17 | +export MISE_INSTALL_PATH=/usr/local/bin/mise |
| 18 | +curl https://mise.run | sh |
| 19 | +MISE_BIN=/usr/local/bin/mise |
| 20 | +"$MISE_BIN" --version |
| 21 | + |
| 22 | +# Activate mise for the remote user's interactive shells. |
| 23 | +echo "eval \"\$(${MISE_BIN} activate bash)\"" >> "${USER_HOME}/.bashrc" |
| 24 | +echo "eval \"\$(${MISE_BIN} activate zsh)\"" >> "${USER_HOME}/.zshenv" |
| 25 | +chown "${USERNAME}:${USERNAME}" "${USER_HOME}/.bashrc" "${USER_HOME}/.zshenv" |
| 26 | + |
| 27 | +# Run a command as the remote user with a sane PATH so mise writes tools into |
| 28 | +# the user's own data dir (~/.local/share/mise) rather than root's. |
| 29 | +as_user() { |
| 30 | + sudo -u "${USERNAME}" -H env "PATH=${USER_HOME}/.local/bin:/usr/local/bin:/usr/bin:/bin" "$@" |
| 31 | +} |
| 32 | + |
| 33 | +# ~/.local/bin is on PATH but nothing creates it now that mise is installed |
| 34 | +# system-wide; ensure it exists for the Chromium symlink below. |
| 35 | +as_user mkdir -p "${USER_HOME}/.local/bin" |
| 36 | + |
| 37 | +# Java is always installed (required for JRuby) and listed in .mise.toml so it |
| 38 | +# is available regardless of which Ruby flavour is used. |
| 39 | +echo "📦 Pre-installing java@temurin-21..." |
| 40 | +as_user "$MISE_BIN" install "java@temurin-21" |
| 41 | +as_user "$MISE_BIN" use --global "java@temurin-21" |
| 42 | + |
| 43 | +# Pre-install Ruby (precompiled) so the container starts immediately. |
| 44 | +echo "📦 Pre-installing ruby@${RUBY_VERSION} (precompiled)..." |
| 45 | +as_user env MISE_RUBY_COMPILE=0 "$MISE_BIN" install "ruby@${RUBY_VERSION}" |
| 46 | +as_user "$MISE_BIN" use --global "ruby@${RUBY_VERSION}" |
| 47 | + |
| 48 | +# Node.js is always needed for the svelte-mini e2e app. |
| 49 | +echo "📦 Pre-installing node@lts..." |
| 50 | +as_user "$MISE_BIN" install "node@lts" |
| 51 | +as_user "$MISE_BIN" use --global "node@lts" |
| 52 | + |
| 53 | +# Install headless Chromium via Playwright (includes all system dependencies) |
| 54 | +# and symlink the binary into ~/.local/bin which is already on PATH. |
| 55 | +echo "📦 Installing headless Chromium via Playwright..." |
| 56 | +as_user "${USER_HOME}/.local/share/mise/shims/npx" playwright install chromium --with-deps |
| 57 | +# Playwright lays out the binary under chrome-linux/ on arm64 and chrome-linux64/ |
| 58 | +# on x86_64 (since Playwright 1.57), so the glob has to match both. |
| 59 | +as_user bash -c "ln -sf ${USER_HOME}/.cache/ms-playwright/chromium-*/chrome-linux*/chrome ${USER_HOME}/.local/bin/chromium" |
| 60 | + |
| 61 | +echo "✅ Toolchain pre-install completed!" |
0 commit comments