Skip to content

Conversation

@rogerheykoop
Copy link

Judge0 Rails 8.0 Upgrade

Overview

This PR upgrades the Judge0 Rails application from Ruby 2.7.0 + Rails 6.1 to Ruby 3.4.1 + Rails 8.0.4.

Architecture Decision

Ruby 3.4 is installed directly in the judge0 Dockerfile, separate from the compilers base image.

  • Rails application: Runs on Ruby 3.4.1 (new)
  • User code submissions: Still use Ruby 2.7.0 from compilers image (unchanged)

The judge0/compilers:1.4.0 base image was intentionally left unchanged.

Version Summary

Component Before After
Ruby (Rails app) 2.7.0 (EOL) 3.4.1
Rails 6.1.7.7 8.0.4
Bundler 2.1.4 2.6.2
Puma 5.x 6.6.1
Redis gem 4.x 5.4.1

Changes Made

Dockerfile

  • Added Ruby 3.4.1 compilation from source
  • Updated PATH to use Ruby 3.4.1
  • Added Debian Buster archive repository fix (EOL workaround)
  • Added bundle config set force_ruby_platform true for native gem compilation

Gemfile

  • Updated Rails to ~> 8.0.0
  • Updated gem versions for Rails 8 compatibility
  • Removed annotate gem (incompatible with Rails 8)

config/application.rb

  • Set config.load_defaults 8.0

config/puma.rb

  • Added default values using ENV.fetch to prevent crashes

config/initializers/resque.rb

  • Removed thread_safe: true option (deprecated in Redis gem 5.x)

config/initializers/secrets.rb (NEW)

  • Compatibility layer for Rails.application.secrets (removed in Rails 7.1+)

docker-compose.dev.yml

  • Added env_file and depends_on to judge0 service

Deleted Files

  • lib/tasks/auto_annotate_models.rake - Referenced removed gem

Breaking Changes Addressed

  1. Rails.application.secrets removed - Created compatibility initializer
  2. Redis gem thread_safe option removed - Removed from resque initializer
  3. Annotate gem incompatibility - Removed gem and rake task
  4. Native gem compilation - Force ruby platform for glibc compatibility
  5. Debian Buster EOL - Redirect apt sources to archive.debian.org

Testing

Verified locally with Docker:

  • GET /languages - 200 OK (48 languages)
  • GET /about - 200 OK (version 1.13.1)

Build Notes

First build takes ~12 minutes due to Ruby compilation. Subsequent builds use cached layers.

rogerheykoop and others added 6 commits December 16, 2025 10:54
This PR upgrades the Judge0 Rails application from the end-of-life Ruby 2.7.0
to Ruby 3.4.1, and from Rails 6.1 to Rails 8.0.4.

Key changes:
- Ruby 3.4.1 compiled from source in Dockerfile (compilers base image unchanged)
- Rails 8.0.4 with updated gem dependencies
- Compatibility layer for Rails.application.secrets (removed in Rails 7.1+)
- Fixed deprecated Redis gem options
- Removed annotate gem (incompatible with Rails 8)
- Added Debian Buster archive repository fix

User code submissions still use Ruby 2.7.0 from the compilers base image.
All API endpoints tested and working.
The original approach of reopening Rails::Application class didn't work in
Rails 8 because the Judge0API::Application class doesn't properly inherit
the dynamically added method.

Changed to use module prepending which ensures the secrets method is
available on the application instance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Dir.exists? was removed in Ruby 3.2+. Updated to use Dir.exist? instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ENV.fetch with a default value still returns empty string when the
variable is set but empty (e.g., RAILS_MAX_THREADS= in config file).
Use .presence to properly fall back to defaults when value is blank.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BREAKING CHANGE: Updated base image from Debian Buster to Ubuntu 22.04

Language updates:
- GCC: 7.4/8.3/9.2 → 11.4/12.3/13.1
- Clang: 7.0.1 → 17
- Python: 2.7/3.8 → 3.11/3.12
- Ruby: 2.7.0 → 3.3.0
- Node.js: 12.14.0 → 20.11.0
- Java: OpenJDK 13 → OpenJDK 21
- Go: 1.13.5 → 1.22.0
- Rust: 1.40.0 → 1.75.0
- TypeScript: 3.7.4 → 5.3.3
- Kotlin: 1.3.70 → 1.9.22
- Swift: 5.2.3 → 5.9.2
- .NET: 3.1 → 8.0
- Scala: 2.13.2 → 3.3.1
- PHP: 7.4.1 → 8.1

New languages added:
- Zig 0.11.0
- Nim 2.0.2
- Dart 3.2
- Julia 1.10.0
- SWI-Prolog 9.0

Removed deprecated languages:
- Python 2.7 (EOL)
- Basic (FBC)
- Octave
- Objective-C
- Visual Basic.Net

Version bumped to 1.14.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use rogerheykoop/compilers:2.0.0 as base image (pending merge to judge0/compilers)
- Remove embedded compiler installations (now in compilers image)
- Keep only Rails application setup (Ruby 3.4.1, bundler, gems)
- Update db/schema.rb to Rails 8.0 format

This restores the proper separation of concerns:
- compilers image: All language compilers/interpreters + isolate sandbox
- judge0 image: Rails application layer only

The Dockerfile is now 75 lines instead of 373 lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant