rails / rails

Ruby on Rails
https://rubyonrails.org
MIT License
55.65k stars 21.57k forks source link

Bug in generated Dockerfile when using ruby preview versions #52998

Open krschacht opened 2 days ago

krschacht commented 2 days ago

Steps to reproduce

Expected behavior

.ruby-version is showing ruby-3.4.0 and:

$ ruby --version
ruby 3.4.0preview1 (2024-05-16 master 9d69619623) [arm64-darwin23]

And this line of the Dockerfile is generated as:

ARG RUBY_VERSION=3.4.0.preview1
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base

So when you run a build you'll see it fail because it's trying to find the image with a period before the word preview

docker.io/library/ruby:3.4.0.preview1-slim

This image does not exist. Instead, RUBY_VERSION should have a dash before the period so that it resolves to this docker image:

docker.io/library/ruby:3.4.0-preview1-slim

I manually edited the file to fix but it's worth fixing the generator.

System configuration

Rails version: 3.4.0-preview1

Ruby version: Rails 7.2.1

whtsht commented 1 day ago

I was able to reproduce the same situation.

Gemfile

source 'https://rubygems.org'
gem 'rails', '7.2.1'

Execute the following command

docker run --rm -it -v $(pwd):/app -w /app ruby:3.4.0-preview1-bullseye bash
bundle install
rails new .
krschacht commented 9 hours ago

I don’t have any comments on PR process. I’ll let the maintainers chime in. But I love the eagerness to get this fixed!