Skip to content

Commit 6a33f0c

Browse files
committed
refactor(devcontainer): drop dep on playwright
We don't use it after all and using it just to get chromium headless was an overkill.
1 parent d291b40 commit 6a33f0c

5 files changed

Lines changed: 35 additions & 42 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ USER sentry
5252
# directory content when a volume is first attached).
5353
RUN mkdir -p /home/sentry/bundle
5454

55-
# mise and the toolchain (Java, Ruby, Node, Chromium) are installed by the local
56-
# `./features/tools` dev container feature, which runs after this Dockerfile —
57-
# see devcontainer.json.
55+
# Chromium, ChromeDriver, mise, and the toolchain (Java, Ruby, Node) are
56+
# installed by the local `./features/tools` dev container feature, which runs
57+
# after this Dockerfile — see devcontainer.json.

.devcontainer/features/tools/devcontainer-feature.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
"name": "sentry-ruby toolchain",
33
"id": "tools",
44
"version": "1.0.0",
5-
"description": "Installs mise and pre-installs the sentry-ruby toolchain (Java, Ruby, Node) via mise plus headless Chromium via Playwright, baked into the image so the container starts without downloading anything.",
5+
"description": "Installs Chromium, ChromeDriver, mise, and the sentry-ruby toolchain (Java, Ruby, Node).",
6+
"installsAfter": [
7+
"ghcr.io/devcontainers/features/git",
8+
"ghcr.io/devcontainers/features/github-cli",
9+
"ghcr.io/nils-geistmann/devcontainers-features/zsh",
10+
"ghcr.io/rocker-org/devcontainer-features/apt-packages"
11+
],
612
"options": {
713
"rubyVersion": {
814
"type": "string",
915
"default": "4.0",
10-
"description": "Ruby version to pre-install and set as the global default (latest 4.0.x by default). Switching versions requires an image rebuild."
16+
"description": "Ruby version to pre-install (latest 4.0.x by default). Switching versions requires an image rebuild."
1117
}
1218
}
1319
}
Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
#!/usr/bin/env bash
22
#
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.
3+
# Installs mise, the sentry-ruby toolchain, and Chromium with ChromeDriver.
64
#
75
set -euo pipefail
86

97
RUBY_VERSION="${RUBYVERSION:-latest}"
108
USERNAME="${_REMOTE_USER:-sentry}"
119
USER_HOME="${_REMOTE_USER_HOME:-/home/${USERNAME}}"
1210

11+
echo "📦 Installing Chromium and ChromeDriver..."
12+
echo "deb http://deb.debian.org/debian sid main" > /etc/apt/sources.list.d/debian.list
13+
wget -qO- https://ftp-master.debian.org/keys/archive-key-12.asc \
14+
| gpg --dearmor > /etc/apt/trusted.gpg.d/debian-archive-keyring.gpg
15+
wget -qO- https://ftp-master.debian.org/keys/archive-key-12-security.asc \
16+
| gpg --dearmor > /etc/apt/trusted.gpg.d/debian-archive-security-keyring.gpg
17+
for directory in bin lib lib32 lib64 libo32 libx32 sbin; do
18+
dpkg-divert --package base-files --no-rename --remove "/${directory}"
19+
done
20+
apt-get update
21+
apt-get install -y --no-install-recommends chromium chromium-driver
22+
rm -rf /var/lib/apt/lists/* /var/cache/apt/* /etc/apt/sources.list.d/debian.list
23+
1324
# Install mise system-wide via the official installer. This downloads a prebuilt
1425
# binary from mise's CDN rather than the GitHub API, avoiding the API rate
1526
# limits the gh-release-based community feature hits on shared CI runners.
@@ -24,38 +35,15 @@ echo "eval \"\$(${MISE_BIN} activate bash)\"" >> "${USER_HOME}/.bashrc"
2435
echo "eval \"\$(${MISE_BIN} activate zsh)\"" >> "${USER_HOME}/.zshenv"
2536
chown "${USERNAME}:${USERNAME}" "${USER_HOME}/.bashrc" "${USER_HOME}/.zshenv"
2637

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.
38+
# Feature installers run as root, but the toolchain belongs to the remote user.
2939
as_user() {
3040
sudo -u "${USERNAME}" -H env "PATH=${USER_HOME}/.local/bin:/usr/local/bin:/usr/bin:/bin" "$@"
3141
}
3242

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 --only-shell
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"
43+
echo "📦 Pre-installing toolchain..."
44+
as_user env MISE_RUBY_COMPILE=0 "$MISE_BIN" install \
45+
"java@temurin-21" \
46+
"ruby@${RUBY_VERSION}" \
47+
"node@lts"
6048

6149
echo "✅ Toolchain pre-install completed!"

.github/workflows/build_images.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
5757

5858
# Build with the dev container CLI (not a plain `docker build`) so the dev
59-
# container features — mise and the local `tools` feature that bakes the
60-
# Ruby/Node/Java/Chromium toolchain — are applied to the pushed image.
59+
# container features — including the local `tools` feature that bakes the
60+
# Ruby/Node/Java toolchain and browser — are applied to the pushed image.
6161
# BASE_IMAGE and RUBY_VERSION are consumed via ${localEnv:...} in
6262
# devcontainer.json, so they are passed as env vars to the CLI here.
6363
- name: Build and push devcontainer image

spec/spec_helper.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
options.add_argument("--disable-gpu")
3232
options.add_argument("--temp-profile")
3333

34-
# Use custom chromium binary if available
35-
chromium_path = "/home/sentry/.local/bin/chromium"
34+
chromium_path = ENV.fetch("SENTRY_E2E_CHROME", "/usr/bin/chromium")
3635
options.binary = chromium_path if File.exist?(chromium_path)
3736

3837
# Use a local chromedriver if provided, bypassing Selenium Manager's
3938
# download (which only ships an x86 driver and fails on arm64).
40-
chromedriver_path = ENV["SENTRY_E2E_CHROMEDRIVER"] || "/home/sentry/.local/bin/chromedriver"
39+
chromedriver_path = ENV.fetch("SENTRY_E2E_CHROMEDRIVER", "/usr/bin/chromedriver")
4140
service = File.exist?(chromedriver_path) ? Selenium::WebDriver::Service.chrome(path: chromedriver_path) : nil
4241

4342
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, service: service)

0 commit comments

Comments
 (0)