Skip to content

Commit 49d75c6

Browse files
takaokoujiclaude
andcommitted
Use Ruby 3.1.5 for Rails 6.1-7.2, Ruby 3.4 for Rails 8.0-8.1
Updated Docker configuration to use specific Ruby versions for each Rails version: - Rails 5.1-6.0: Ruby 2.7 with bundler 2.4.22 - Rails 6.1-7.2: Ruby 3.1.5 with bundler 2.4.14 - Rails 8.0-8.1: Ruby 3.4 with bundler 2.4.14 Rails 8.0+ requires Ruby >= 3.2.0, so we use Ruby 3.4 for these versions. All tests pass successfully for all 9 Rails versions. Changes: - Created Dockerfile.ruby3.1 for Ruby 3.1.5 - Created Dockerfile.ruby3.4 for Ruby 3.4 - Updated docker-compose.yml to use appropriate Ruby versions - Added separate bundle cache volumes for each Ruby version Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d78b012 commit 49d75c6

3 files changed

Lines changed: 53 additions & 14 deletions

File tree

Dockerfile.ruby3.1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ WORKDIR /app
1515
COPY Gemfile jsonapi-resources.gemspec ./
1616
COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/
1717

18-
# Install bundler
19-
RUN gem install bundler
18+
# Install specific bundler version for compatibility
19+
RUN gem install bundler -v 2.4.14 --no-document && \
20+
gem install bundler -v 2.4.14 --install-dir /usr/local/bundle --no-document && \
21+
bundle --version
2022

2123
# Note: bundle install will happen at runtime with specific RAILS_VERSION
2224
# This allows testing multiple Rails versions without rebuilding the image

Dockerfile.ruby3.4

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dockerfile for testing jsonapi-resources with Rails 8.0-8.1 (Ruby 3.4)
2+
3+
FROM ruby:3.4
4+
5+
# Install dependencies
6+
RUN apt-get update -qq && \
7+
apt-get install -y build-essential libpq-dev nodejs && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Set working directory
12+
WORKDIR /app
13+
14+
# Copy Gemfile and gemspec
15+
COPY Gemfile jsonapi-resources.gemspec ./
16+
COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/
17+
18+
# Install specific bundler version for compatibility
19+
RUN gem install bundler -v 2.4.14 --no-document && \
20+
gem install bundler -v 2.4.14 --install-dir /usr/local/bundle --no-document && \
21+
bundle --version
22+
23+
# Note: bundle install will happen at runtime with specific RAILS_VERSION
24+
# This allows testing multiple Rails versions without rebuilding the image

docker-compose.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
dockerfile: Dockerfile.ruby3.1
77
volumes:
88
- .:/app
9-
- bundle-cache:/usr/local/bundle
9+
- bundle-cache-ruby31:/usr/local/bundle
1010
working_dir: /app
1111
stdin_open: true
1212
tty: true
@@ -23,6 +23,18 @@ services:
2323
stdin_open: true
2424
tty: true
2525

26+
# Base service definition for Ruby 3.4 (Rails 8.0-8.1)
27+
test-base-ruby34: &test-base-ruby34
28+
build:
29+
context: .
30+
dockerfile: Dockerfile.ruby3.4
31+
volumes:
32+
- .:/app
33+
- bundle-cache-ruby34:/usr/local/bundle
34+
working_dir: /app
35+
stdin_open: true
36+
tty: true
37+
2638
# Rails 5.1.7
2739
rails-5.1:
2840
<<: *test-base-ruby27
@@ -53,47 +65,47 @@ services:
5365
container_name: jsonapi-rails-6.1
5466
environment:
5567
- RAILS_VERSION=6.1.7.10
56-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
68+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
5769

5870
# Rails 7.0.10
5971
rails-7.0:
6072
<<: *test-base
6173
container_name: jsonapi-rails-7.0
6274
environment:
6375
- RAILS_VERSION=7.0.10
64-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
76+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
6577

6678
# Rails 7.1.6
6779
rails-7.1:
6880
<<: *test-base
6981
container_name: jsonapi-rails-7.1
7082
environment:
7183
- RAILS_VERSION=7.1.6
72-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
84+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
7385

7486
# Rails 7.2.3
7587
rails-7.2:
7688
<<: *test-base
7789
container_name: jsonapi-rails-7.2
7890
environment:
7991
- RAILS_VERSION=7.2.3
80-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
92+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
8193

82-
# Rails 8.0.4
94+
# Rails 8.0.4 (Ruby 3.4 required)
8395
rails-8.0:
84-
<<: *test-base
96+
<<: *test-base-ruby34
8597
container_name: jsonapi-rails-8.0
8698
environment:
8799
- RAILS_VERSION=8.0.4
88-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
100+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
89101

90-
# Rails 8.1.2
102+
# Rails 8.1.2 (Ruby 3.4 required)
91103
rails-8.1:
92-
<<: *test-base
104+
<<: *test-base-ruby34
93105
container_name: jsonapi-rails-8.1
94106
environment:
95107
- RAILS_VERSION=8.1.2
96-
command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test"
108+
command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test"
97109

98110
# Interactive shell for debugging (defaults to Rails 8.1)
99111
shell:
@@ -104,5 +116,6 @@ services:
104116
command: /bin/bash
105117

106118
volumes:
107-
bundle-cache:
119+
bundle-cache-ruby31:
108120
bundle-cache-ruby27:
121+
bundle-cache-ruby34:

0 commit comments

Comments
 (0)