Skip to content

Commit f2ca3cc

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 and 7.0 - Add .dockerignore to exclude unnecessary files from Docker context - Update .gitignore to use coverage/ directory and remove duplicate entry This provides an easy way to test the gem with different Rails versions in isolated Docker environments.
1 parent e92afc6 commit f2ca3cc

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

.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
test_db
2322
test_db-journal

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dockerfile for testing jsonapi-resources with multiple Rails versions
2+
3+
FROM ruby:3.2
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 bundler
19+
RUN gem install bundler
20+
21+
# Note: bundle install will happen at runtime with specific RAILS_VERSION
22+
# This allows testing multiple Rails versions without rebuilding the image

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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
15+
rails-6.1:
16+
<<: *test-base
17+
container_name: jsonapi-rails-6.1
18+
environment:
19+
- RAILS_VERSION=6.1.7
20+
command: bash -c "bundle update && bundle exec rake test"
21+
22+
# Rails 7.0.4
23+
rails-7.0:
24+
<<: *test-base
25+
container_name: jsonapi-rails-7.0
26+
environment:
27+
- RAILS_VERSION=7.0.4
28+
command: bash -c "bundle update && bundle exec rake test"
29+
30+
# Interactive shell for debugging (defaults to Rails 6.1)
31+
shell:
32+
<<: *test-base
33+
container_name: jsonapi-shell
34+
environment:
35+
- RAILS_VERSION=${RAILS_VERSION:-6.1.7}
36+
command: /bin/bash
37+
38+
volumes:
39+
bundle-cache:

0 commit comments

Comments
 (0)