Skip to content

Commit 4d2a832

Browse files
committed
Add build_images workflow
1 parent c3b84fe commit 4d2a832

4 files changed

Lines changed: 84 additions & 53 deletions

File tree

.devcontainer/.env.example

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Official Ruby images
2-
IMAGE=ruby
2+
IMAGE="ruby:3.4.5-slim-bookworm"
33

4-
# Adjust as needed
5-
VERSION=3.4.5
6-
7-
# IMAGE=jruby
8-
# TAG=latest
4+
# IMAGE="jruby:latest"
95

106
# E2E testing
117
SENTRY_DSN="http://user:pass@sentry.localhost/project/42"

.devcontainer/Dockerfile

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
ARG IMAGE="ruby"
2-
ARG VERSION="3.4.5"
3-
ARG DISTRO="slim-bookworm"
42

5-
FROM ${IMAGE}:${VERSION}-${DISTRO} AS build
3+
FROM ${IMAGE} AS build
64

75
RUN apt-get update && apt-get install -y --no-install-recommends \
86
sudo \
@@ -40,37 +38,13 @@ WORKDIR /workspace/sentry
4038
RUN chown -R sentry:sentry /workspace/sentry
4139

4240
ARG VERSION
43-
ARG GEM_HOME="/workspace/gems/${VERSION}"
44-
45-
RUN mkdir /workspace/gems && chown -R sentry:sentry /workspace/gems
41+
ARG GEM_HOME="/workspace/sentry/vendor/gems/${VERSION}"
4642

4743
ENV LANG=C.UTF-8 \
4844
BUNDLE_JOBS=4 \
4945
BUNDLE_RETRY=3 \
50-
GEM_HOME=/workspace/gems/${VERSION} \
46+
GEM_HOME=/workspace/sentry/vendor/gems/${VERSION} \
5147
PATH=$PATH:${GEM_HOME}/bin \
5248
REDIS_HOST=redis
5349

54-
FROM build AS dev
55-
5650
USER sentry
57-
58-
COPY .devcontainer/entrypoint.sh /workspace/entrypoint.sh
59-
60-
ENTRYPOINT ["/workspace/entrypoint.sh"]
61-
62-
FROM build AS test
63-
64-
COPY . .
65-
66-
RUN chown -R sentry:sentry .
67-
68-
USER sentry
69-
70-
RUN gem install foreman && \
71-
bundle install && \
72-
cd spec/apps/rails-mini && \
73-
bundle install
74-
75-
RUN cd spec/apps/svelte-mini && \
76-
npm install

.devcontainer/docker-compose.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,40 @@
11
services:
22
sentry-build: &sentry-build
3+
image: ${DOCKER_IMAGE:-sentry-ruby-devcontainer}:${DOCKER_TAG:-latest}
34
build:
45
context: ..
56
dockerfile: .devcontainer/Dockerfile
6-
target: test
77
args:
88
IMAGE: ${IMAGE}
9-
VERSION: ${VERSION}
10-
SENTRY_E2E_RAILS_APP_PORT: ${SENTRY_E2E_RAILS_APP_PORT}
11-
SENTRY_E2E_SVELTE_APP_PORT: ${SENTRY_E2E_SVELTE_APP_PORT}
12-
SENTRY_E2E_RAILS_APP_URL: ${SENTRY_E2E_RAILS_APP_URL}
13-
SENTRY_E2E_SVELTE_APP_URL: ${SENTRY_E2E_SVELTE_APP_URL}
149
volumes:
1510
- ..:/workspace/sentry:cached
16-
- sentry_e2e_logs:/workspace/sentry/log
1711
working_dir: /workspace/sentry
18-
environment:
19-
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
2012
env_file: [".env"]
2113

2214
sentry-dev:
2315
<<: *sentry-build
24-
command: sleep infinity
16+
entrypoint: ".devcontainer/run --service dev"
17+
command: "sleep infinity"
2518
depends_on:
2619
- redis
2720

2821
sentry-test:
2922
<<: *sentry-build
23+
entrypoint: ".devcontainer/run --service test"
3024
depends_on:
31-
- redis
3225
- sentry-test-services
3326

3427
sentry-test-services:
3528
<<: *sentry-build
29+
entrypoint: ".devcontainer/run --service test-services"
3630
command: "foreman start"
3731
ports:
38-
- ${SENTRY_E2E_RAILS_APP_PORT}
39-
- ${SENTRY_E2E_SVELTE_APP_PORT}
32+
- "${SENTRY_E2E_RAILS_APP_PORT}:4000"
33+
- "${SENTRY_E2E_SVELTE_APP_PORT}:4001"
4034

4135
redis:
4236
image: redis:latest
4337
environment:
4438
- ALLOW_EMPTY_PASSWORD=yes
4539
ports:
4640
- "6379:6379"
47-
48-
volumes:
49-
sentry_e2e_logs:
50-
sentry_ruby_gems:
51-
sentry_node_modules:

.github/workflows/build_images.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Build & push devcontainer"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- .devcontainer/**
9+
- .github/workflows/build_images.yml
10+
11+
# Uncomment if you want to test things out in a PR
12+
#
13+
# pull_request:
14+
# paths:
15+
# - .devcontainer/**
16+
# - .github/workflows/build_images.yml
17+
18+
permissions:
19+
contents: read
20+
packages: write # Required for GHCR
21+
22+
jobs:
23+
build-and-push:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
ruby_image:
28+
- ruby:2.7.8-slim-bullseye
29+
- ruby:3.0.7-slim-bullseye
30+
- ruby:3.1.7-slim-bookworm
31+
- ruby:3.2.9-slim-bookworm
32+
- ruby:3.3.9-slim-bookworm
33+
- ruby:3.4.5-slim-bookworm
34+
35+
steps:
36+
- name: Check out current commit
37+
uses: actions/checkout@v4
38+
39+
- name: Generate short image name
40+
id: image_name
41+
run: |
42+
ruby_image="${{ matrix.ruby_image }}"
43+
44+
if [[ "$ruby_image" == ruby:* ]]; then
45+
version=$(echo "$ruby_image" | cut -d: -f2 | cut -d. -f1,2)
46+
short_name="sentry-ruby-devcontainer-${version}"
47+
elif [[ "$ruby_image" == jruby:latest ]]; then
48+
short_name="sentry-ruby-devcontainer-jruby-latest"
49+
elif [[ "$ruby_image" == jruby:* ]]; then
50+
version=$(echo "$ruby_image" | cut -d: -f2 | cut -d. -f1,2)
51+
short_name="sentry-ruby-devcontainer-jruby-${version}"
52+
else
53+
short_name="sentry-ruby-devcontainer-${ruby_image}"
54+
fi
55+
56+
echo "short_name=${short_name}" >> $GITHUB_OUTPUT
57+
echo "Generated short image name: ${short_name}"
58+
59+
- name: Build and push devcontainer image
60+
id: build
61+
uses: getsentry/action-build-and-push-images@main
62+
with:
63+
image_name: '${{ steps.image_name.outputs.short_name }}'
64+
dockerfile_path: '.devcontainer/Dockerfile'
65+
ghcr: true
66+
publish_on_pr: true
67+
build_args: |
68+
IMAGE=${{ matrix.ruby_image }}
69+
70+
- name: Use outputs
71+
run: |
72+
echo "GHCR URL: ${{ steps.build.outputs.ghcr_image_url }}"

0 commit comments

Comments
 (0)