Skip to content

Commit 06effb1

Browse files
committed
Add build_images workflow
1 parent 64f5250 commit 06effb1

File tree

4 files changed

+81
-53
lines changed

4 files changed

+81
-53
lines changed

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

0 commit comments

Comments
 (0)