Skip to content

Commit 869dc8b

Browse files
authored
chore(devcontainer): consolidate and simplify dev/test/ci envs (#3020)
* chore(devcontainer): simpler setup w/o docker compose * refactor(devcontainer): rename run to ci-run as now only CI needs it * chore(devcontainer): for e2e install playwright in headless only * refactor(devcontainer): drop dep on playwright We don't use it after all and using it just to get chromium headless was an overkill. * chore(devcontainer): bump version * chore(devcontainer): bump version * refactor(devcontainer): use "latest" for the ruby version * chore(devcontainer): bump version * refactor(devcontainer): add redis-server as a dev/test/ci dep * chore(devcontainer): bump version * refactor(devcontainer): install mise via feature * chore(devcontainer): bump version * fix(ci): make ancient rubies compile under Apple Ms arch
1 parent 9f70c7a commit 869dc8b

18 files changed

Lines changed: 232 additions & 197 deletions

.devcontainer/.env.example

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
# Devcontainer configuration
2-
RUBY_VERSION="3.4.9"
2+
3+
RUBY_VERSION=3.4.9
34

45
# E2E testing
5-
SENTRY_DSN="http://user:pass@sentry.localhost/project/42"
6-
# SENTRY_DSN_JS="http://user:pass@sentry-js.localhost/project/43"
7-
SENTRY_DSN_JS=""
6+
SENTRY_DSN=http://user:pass@sentry.localhost/project/42
7+
# SENTRY_DSN_JS=http://user:pass@sentry-js.localhost/project/43
8+
SENTRY_DSN_JS=
89

910
SENTRY_E2E_RAILS_APP_PORT=4000
1011
SENTRY_E2E_SVELTE_APP_PORT=4001
1112

12-
SENTRY_E2E_RAILS_APP_URL="http://localhost:4000"
13-
SENTRY_E2E_SVELTE_APP_URL="http://localhost:4001"
13+
SENTRY_E2E_RAILS_APP_URL=http://localhost:4000
14+
SENTRY_E2E_SVELTE_APP_URL=http://localhost:4001
1415

1516
# ActiveJob queue adapter under test: async | inline | sidekiq | resque | delayed_job | solid_queue
16-
SENTRY_E2E_ACTIVE_JOB_ADAPTER="async"
17-
18-
# Redis for the sidekiq/resque adapters (the Compose service is named "redis")
19-
REDIS_URL="redis://redis:6379"
17+
SENTRY_E2E_ACTIVE_JOB_ADAPTER=async
2018

21-
# Faster builds with compose
22-
COMPOSE_BAKE=true
19+
# Redis for the sidekiq/resque adapters
20+
REDIS_URL=redis://localhost:6379

.devcontainer/Dockerfile

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ RUN userdel -r ubuntu 2>/dev/null || true \
3535
&& groupadd --gid 1000 sentry \
3636
&& useradd --uid 1000 --gid sentry --shell /bin/bash --create-home sentry
3737

38-
WORKDIR /workspace/sentry
38+
WORKDIR /workspaces/sentry-ruby
3939

40-
RUN chown -R sentry:sentry /workspace/sentry
40+
RUN chown -R sentry:sentry /workspaces/sentry-ruby
4141

4242
ENV LANG=C.UTF-8 \
4343
BUNDLE_JOBS=4 \
4444
BUNDLE_RETRY=3 \
45-
REDIS_HOST=redis \
45+
REDIS_HOST=localhost \
4646
PATH=/home/sentry/.local/share/mise/shims:/home/sentry/.local/bin:$PATH
4747

4848
USER sentry
@@ -52,32 +52,6 @@ USER sentry
5252
# directory content when a volume is first attached).
5353
RUN mkdir -p /home/sentry/bundle
5454

55-
RUN curl https://mise.run | sh \
56-
&& echo 'eval "$(/home/sentry/.local/bin/mise activate bash)"' >> /home/sentry/.bashrc \
57-
&& echo 'eval "$(/home/sentry/.local/bin/mise activate zsh)"' >> /home/sentry/.zshenv
58-
59-
# Pre-install Ruby at build time so the container starts immediately without
60-
# downloading it at runtime. Switching Ruby versions requires a rebuild.
61-
ARG RUBY_VERSION=latest
62-
63-
# Java is always installed (required for JRuby). It is listed in .mise.toml so
64-
# it is available for all users regardless of which Ruby flavour they use.
65-
RUN echo "📦 Pre-installing java@temurin-21..." && \
66-
/home/sentry/.local/bin/mise install "java@temurin-21" && \
67-
/home/sentry/.local/bin/mise use --global "java@temurin-21"
68-
69-
RUN echo "📦 Pre-installing ruby@${RUBY_VERSION} (precompiled)..." && \
70-
MISE_RUBY_COMPILE=0 /home/sentry/.local/bin/mise install "ruby@${RUBY_VERSION}" && \
71-
/home/sentry/.local/bin/mise use --global "ruby@${RUBY_VERSION}"
72-
73-
# Node.js is always needed for the svelte-mini e2e app.
74-
RUN echo "📦 Pre-installing node@lts..." && \
75-
/home/sentry/.local/bin/mise install "node@lts" && \
76-
/home/sentry/.local/bin/mise use --global "node@lts"
77-
78-
# Install headless Chromium via Playwright (includes all system dependencies).
79-
# Symlink the binary into ~/.local/bin which is already on PATH.
80-
RUN /home/sentry/.local/share/mise/shims/npx playwright install chromium --with-deps
81-
# Playwright lays out the binary under chrome-linux/ on arm64 and chrome-linux64/
82-
# on x86_64 (since Playwright 1.57), so the glob has to match both.
83-
RUN bash -c 'ln -sf /home/sentry/.cache/ms-playwright/chromium-*/chrome-linux*/chrome /home/sentry/.local/bin/chromium'
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/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
2.3.1

.devcontainer/ci-run

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
readonly WORKSPACE=/workspaces/sentry-ruby
6+
7+
sudo chown -R sentry:sentry "$WORKSPACE"
8+
9+
cd "$WORKSPACE"
10+
mise trust "$WORKSPACE" >/dev/null
11+
12+
exec "$@"
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
{
22
"features": {
3-
"ghcr.io/devcontainers-extra/features/npm-packages:latest": {
4-
"version": "1.0.1",
5-
"resolved": "ghcr.io/devcontainers-extra/features/npm-packages@sha256:0851cc312204f4044f22230986134026409565f9e632d8ab2b8c639e81cedd7c",
6-
"integrity": "sha256:0851cc312204f4044f22230986134026409565f9e632d8ab2b8c639e81cedd7c"
3+
"ghcr.io/devcontainers-extra/features/mise:latest": {
4+
"version": "1.0.0",
5+
"resolved": "ghcr.io/devcontainers-extra/features/mise@sha256:5c389ab1e3c8e44e5e0ff119f6868d54dbb781bc860bd8587dc66209cb8c4a8c",
6+
"integrity": "sha256:5c389ab1e3c8e44e5e0ff119f6868d54dbb781bc860bd8587dc66209cb8c4a8c"
77
},
88
"ghcr.io/devcontainers/features/git:latest": {
9-
"version": "1.3.5",
10-
"resolved": "ghcr.io/devcontainers/features/git@sha256:27905dc196c01f77d6ba8709cb82eeaf330b3b108772e2f02d1cd0d826de1251",
11-
"integrity": "sha256:27905dc196c01f77d6ba8709cb82eeaf330b3b108772e2f02d1cd0d826de1251"
9+
"version": "1.3.8",
10+
"resolved": "ghcr.io/devcontainers/features/git@sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2",
11+
"integrity": "sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2"
1212
},
1313
"ghcr.io/devcontainers/features/github-cli:latest": {
1414
"version": "1.1.0",
1515
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671",
1616
"integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671"
1717
},
18-
"ghcr.io/devcontainers/features/node:latest": {
19-
"version": "2.0.0",
20-
"resolved": "ghcr.io/devcontainers/features/node@sha256:fedd4c11f7adfb64283b578dddc7da906728daa25fa293351c9d913231acf12f",
21-
"integrity": "sha256:fedd4c11f7adfb64283b578dddc7da906728daa25fa293351c9d913231acf12f"
22-
},
2318
"ghcr.io/nils-geistmann/devcontainers-features/zsh:latest": {
2419
"version": "0.0.8",
2520
"resolved": "ghcr.io/nils-geistmann/devcontainers-features/zsh@sha256:fd57a61a5187480b5e73f8041be5b67005be48f06503736df6cfdd8d0f38f3c4",
@@ -31,4 +26,4 @@
3126
"integrity": "sha256:87a4d7750a596a5db034ba8508782f31aebdc2ffe955c66aaecb33d9de2ecdae"
3227
}
3328
}
34-
}
29+
}

.devcontainer/devcontainer.json

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
11
{
22
"name": "sentry-ruby",
3-
"dockerComposeFile": "docker-compose.yml",
4-
"service": "sentry-dev",
5-
"workspaceFolder": "/workspace/sentry",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"BASE_IMAGE": "${localEnv:BASE_IMAGE:ubuntu:24.04}"
8+
}
9+
},
10+
"runArgs": ["--init"],
11+
"mounts": [
12+
"source=sentry-ruby-bundle,target=/home/sentry/bundle,type=volume"
13+
],
14+
"forwardPorts": [4000, 4001, 6379],
15+
"containerEnv": {
16+
"BUNDLE_PATH": "/home/sentry/bundle",
17+
"SENTRY_DSN": "http://user:pass@sentry.localhost/project/42",
18+
"SENTRY_DSN_JS": "",
19+
"SENTRY_E2E_RAILS_APP_PORT": "4000",
20+
"SENTRY_E2E_SVELTE_APP_PORT": "4001",
21+
"SENTRY_E2E_RAILS_APP_URL": "http://localhost:4000",
22+
"SENTRY_E2E_SVELTE_APP_URL": "http://localhost:4001",
23+
"SENTRY_E2E_ACTIVE_JOB_ADAPTER": "async",
24+
"REDIS_URL": "redis://localhost:6379"
25+
},
26+
"postCreateCommand": "mise trust /workspaces/sentry-ruby",
27+
"postStartCommand": "mise run services:redis",
628
"features": {
729
"ghcr.io/devcontainers/features/git:latest": {
830
"ppa": false,
931
"version": "2.54.0"
1032
},
1133
"ghcr.io/devcontainers/features/github-cli:latest": {},
1234
"ghcr.io/nils-geistmann/devcontainers-features/zsh:latest": {},
13-
"ghcr.io/devcontainers/features/node:latest": {},
14-
"ghcr.io/devcontainers-extra/features/npm-packages:latest": {},
35+
"ghcr.io/devcontainers-extra/features/mise:latest": {},
36+
"./features/tools": {
37+
"rubyVersion": "${localEnv:RUBY_VERSION:4.0}"
38+
},
1539
"ghcr.io/rocker-org/devcontainer-features/apt-packages:latest": {
16-
"packages": "inotify-tools,tzdata"
40+
"packages": "inotify-tools,tzdata,redis-server"
1741
}
1842
},
1943
"customizations": {

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "sentry-ruby toolchain",
3+
"id": "tools",
4+
"version": "1.0.0",
5+
"description": "Installs development dependencies required by the Ruby SDK to run all tests",
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+
"ghcr.io/devcontainers-extra/features/mise"
12+
],
13+
"options": {
14+
"rubyVersion": {
15+
"type": "string",
16+
"default": "latest",
17+
"description": "Ruby version to pre-install. Switching versions requires an image rebuild."
18+
}
19+
}
20+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Installs the sentry-ruby toolchain.
4+
#
5+
set -euo pipefail
6+
7+
RUBY_VERSION="${RUBYVERSION:-latest}"
8+
USERNAME="${_REMOTE_USER:-sentry}"
9+
USER_HOME="${_REMOTE_USER_HOME:-/home/${USERNAME}}"
10+
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+
24+
MISE_BIN="$(command -v mise || echo /usr/local/bin/mise)"
25+
"$MISE_BIN" --version
26+
27+
# Activate mise for the remote user's interactive shells.
28+
echo "eval \"\$(${MISE_BIN} activate bash)\"" >> "${USER_HOME}/.bashrc"
29+
echo "eval \"\$(${MISE_BIN} activate zsh)\"" >> "${USER_HOME}/.zshenv"
30+
chown "${USERNAME}:${USERNAME}" "${USER_HOME}/.bashrc" "${USER_HOME}/.zshenv"
31+
32+
# Feature installers run as root, but the toolchain belongs to the remote user.
33+
as_user() {
34+
sudo -u "${USERNAME}" -H env "PATH=${USER_HOME}/.local/bin:/usr/local/bin:/usr/bin:/bin" "$@"
35+
}
36+
37+
echo "📦 Pre-installing toolchain..."
38+
as_user env MISE_RUBY_COMPILE=0 "$MISE_BIN" install \
39+
"java@temurin-21" \
40+
"ruby@${RUBY_VERSION}" \
41+
"node@lts"
42+
43+
echo "✅ Toolchain pre-install completed!"

.devcontainer/run

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)