-
Notifications
You must be signed in to change notification settings - Fork 44
expand check to match Rails generated Dockerfiles #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
An example: ``` ARG RUBY_VERSION=3.4.2 FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with possible suggestion
@@ -418,7 +418,7 @@ def generate_app | |||
# Older versions no longer release new images | |||
matching_ruby = [">= 3.4.2", "~> 3.3.7", "~> 3.2.7", "~> 3.1.7"].any? { |v| Gem::Requirement.new(v).satisfied_by?(Gem.ruby_version) } | |||
# Only slim and alpine are missing libyaml-dev/yaml-dev | |||
matching_image = /FROM ruby:.+-(alpine|slim)/i.match?(dockerfile) | |||
matching_image = /FROM .*ruby:.+-(alpine|slim)/i.match?(dockerfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
matching_image = /FROM .*ruby:.+-(alpine|slim)/i.match?(dockerfile) | |
matching_image = /FROM .*\/ruby:.+-(alpine|slim)/i.match?(dockerfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That suggestion is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matching_image = /FROM .*ruby:.+-(alpine|slim)/i.match?(dockerfile) | |
# https://rubular.com/r/Jb4LEfrMSmxkp9 | |
matching_image = /FROM (.*\/)?ruby:(.+-)?(alpine|slim)/i.match?(dockerfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should do the trick:
@@ -418,7 +418,7 @@ class DockerfileGenerator < Rails::Generators::Base
# Older versions no longer release new images
matching_ruby = [">= 3.4.2", "~> 3.3.7", "~> 3.2.7", "~> 3.1.7"].any? { |v| Gem::Requirement.new(v).satisfied_by?(Gem.ruby_version) }
# Only slim and alpine are missing libyaml-dev/yaml-dev
- matching_image = /FROM .*ruby:.+-(alpine|slim)/i.match?(dockerfile)
+ matching_image = /FROM (|.+/)ruby:.+-(alpine|slim)/i.match?(dockerfile)
Did you notice my updated suggestion with test cases? |
An example: