Update the Rails app devcontainer to use the Rail's orgs ruby image
This commit is contained in:
parent
6b5f05821b
commit
5fcbc2c421
@ -4,10 +4,6 @@ module Rails
|
||||
module Generators
|
||||
module Devcontainer
|
||||
private
|
||||
def devcontainer_ruby_version
|
||||
gem_ruby_version.to_s.match(/^\d+\.\d+/).to_s
|
||||
end
|
||||
|
||||
def devcontainer_dependencies
|
||||
return @devcontainer_dependencies if @devcontainer_dependencies
|
||||
|
||||
@ -63,6 +59,13 @@ def db_volume_name_for_devcontainer(database = options[:database])
|
||||
end
|
||||
end
|
||||
|
||||
def db_package_for_dockerfile(database = options[:database])
|
||||
case database
|
||||
when "mysql" then "default-libmysqlclient-dev"
|
||||
when "postgresql" then "libpq-dev"
|
||||
end
|
||||
end
|
||||
|
||||
def devcontainer_db_service_yaml(**options)
|
||||
return unless service = db_service_for_devcontainer
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
||||
ARG RUBY_VERSION=<%= devcontainer_ruby_version %>
|
||||
FROM mcr.microsoft.com/devcontainers/ruby:1-$RUBY_VERSION-bookworm
|
||||
ARG RUBY_VERSION=<%= gem_ruby_version %>
|
||||
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
|
||||
|
||||
<%- unless options.skip_active_storage -%>
|
||||
# Install packages needed to build gems
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
libvips \
|
||||
<%= db_package_for_dockerfile %> libvips \
|
||||
# For video thumbnails
|
||||
ffmpeg \
|
||||
# For pdf thumbnails. If you want to use mupdf instead of poppler,
|
||||
|
@ -1011,8 +1011,7 @@ def test_inclusion_of_ruby_version
|
||||
ruby_version = "#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}"
|
||||
|
||||
assert_file ".devcontainer/Dockerfile" do |content|
|
||||
minor_ruby_version = ruby_version.match(/^\d+\.\d+/).to_s
|
||||
assert_match(/ARG RUBY_VERSION=#{minor_ruby_version}$/, content)
|
||||
assert_match(/ARG RUBY_VERSION=#{ruby_version}$/, content)
|
||||
end
|
||||
assert_file "Dockerfile" do |content|
|
||||
assert_match(/ARG RUBY_VERSION=#{ruby_version}/, content)
|
||||
@ -1320,6 +1319,9 @@ def test_devonctainer_postgresql
|
||||
assert_file("config/database.yml") do |content|
|
||||
assert_match(/host: <%= ENV\["DB_HOST"\] %>/, content)
|
||||
end
|
||||
assert_file(".devcontainer/Dockerfile") do |content|
|
||||
assert_match(/libpq-dev/, content)
|
||||
end
|
||||
end
|
||||
|
||||
def test_devonctainer_mysql
|
||||
@ -1348,6 +1350,9 @@ def test_devonctainer_mysql
|
||||
assert_file("config/database.yml") do |content|
|
||||
assert_match(/host: <%= ENV.fetch\("DB_HOST"\) \{ "localhost" } %>/, content)
|
||||
end
|
||||
assert_file(".devcontainer/Dockerfile") do |content|
|
||||
assert_match(/default-libmysqlclient-dev/, content)
|
||||
end
|
||||
end
|
||||
|
||||
def test_devonctainer_mariadb
|
||||
|
Loading…
Reference in New Issue
Block a user