Skip to content

Commit 90684e6

Browse files
committed
Add Docker support for multi-version Rails testing
- Add Dockerfile with Ruby 3.2 and required dependencies - Add docker-compose.yml with services for Rails 6.1, 7.0, 7.1, 7.2, 8.0, and 8.1.2 - Add .dockerignore to exclude unnecessary files from Docker context - Update .gitignore to use coverage/ directory and remove duplicate entry
1 parent 85d6cce commit 90684e6

4 files changed

Lines changed: 138 additions & 2 deletions

File tree

.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Claude/AI configuration
7+
.claude
8+
.serena
9+
CLAUDE.md
10+
11+
# Documentation
12+
*.md
13+
!README.md
14+
15+
# Test artifacts
16+
coverage/
17+
test_db
18+
*.sqlite3
19+
.last_run.json
20+
.resultset.json
21+
22+
# Ruby/bundler
23+
.bundle
24+
vendor/bundle
25+
26+
# OS files
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Editor files
31+
.vscode
32+
.idea
33+
*.swp
34+
*.swo
35+
*~

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Gemfile.lock
99
InstalledFiles
1010
_yardoc
11-
coverage
11+
coverage/
1212
doc/
1313
lib/bundler/man
1414
pkg
@@ -17,7 +17,6 @@ spec/reports
1717
test/tmp
1818
test/version_tmp
1919
tmp
20-
coverage
2120
test/log
2221
log/*.log
2322
test_db

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Dockerfile for testing jsonapi-resources with multiple Rails versions
2+
FROM ruby:3.2
3+
4+
# Install dependencies
5+
RUN apt-get update -qq && \
6+
apt-get install -y build-essential libsqlite3-dev nodejs && \
7+
apt-get clean && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
# Set working directory
11+
WORKDIR /app
12+
13+
# Copy gemspec and Gemfile first for better caching
14+
COPY jsonapi-resources.gemspec Gemfile ./
15+
COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/
16+
17+
# Install bundler
18+
RUN gem install bundler
19+
20+
# Set default Rails version (can be overridden via build arg or env var)
21+
ARG RAILS_VERSION=6.1.7.10
22+
ENV RAILS_VERSION=${RAILS_VERSION}
23+
24+
# Install dependencies
25+
RUN bundle install
26+
27+
# Copy the rest of the application
28+
COPY . .
29+
30+
# Default command runs tests
31+
CMD ["bundle", "exec", "rake", "test"]

docker-compose.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
services:
2+
# Base service definition
3+
test-base: &test-base
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
volumes:
8+
- .:/app
9+
- bundle-cache:/usr/local/bundle
10+
working_dir: /app
11+
stdin_open: true
12+
tty: true
13+
14+
# Rails 6.1.7.10
15+
rails-6.1:
16+
<<: *test-base
17+
container_name: jsonapi-rails-6.1
18+
environment:
19+
- RAILS_VERSION=6.1.7.10
20+
command: bash -c "bundle update && bundle exec rake test"
21+
22+
# Rails 7.0.10
23+
rails-7.0:
24+
<<: *test-base
25+
container_name: jsonapi-rails-7.0
26+
environment:
27+
- RAILS_VERSION=7.0.10
28+
command: bash -c "bundle update && bundle exec rake test"
29+
30+
# Rails 7.1.6
31+
rails-7.1:
32+
<<: *test-base
33+
container_name: jsonapi-rails-7.1
34+
environment:
35+
- RAILS_VERSION=7.1.6
36+
command: bash -c "bundle update && bundle exec rake test"
37+
38+
# Rails 7.2.3
39+
rails-7.2:
40+
<<: *test-base
41+
container_name: jsonapi-rails-7.2
42+
environment:
43+
- RAILS_VERSION=7.2.3
44+
command: bash -c "bundle update && bundle exec rake test"
45+
46+
# Rails 8.0.4
47+
rails-8.0:
48+
<<: *test-base
49+
container_name: jsonapi-rails-8.0
50+
environment:
51+
- RAILS_VERSION=8.0.4
52+
command: bash -c "bundle update && bundle exec rake test"
53+
54+
# Rails 8.1.2
55+
rails-8.1:
56+
<<: *test-base
57+
container_name: jsonapi-rails-8.1
58+
environment:
59+
- RAILS_VERSION=8.1.2
60+
command: bash -c "bundle update && bundle exec rake test"
61+
62+
# Interactive shell for debugging (defaults to Rails 6.1)
63+
shell:
64+
<<: *test-base
65+
container_name: jsonapi-shell
66+
environment:
67+
- RAILS_VERSION=${RAILS_VERSION:-6.1.7.10}
68+
command: /bin/bash
69+
70+
volumes:
71+
bundle-cache:

0 commit comments

Comments
 (0)