change from deploy to base

This commit is contained in:
Achmad Chun Chun 2024-02-13 22:19:12 +07:00
parent 78061ebfe8
commit bdb8a6dcf7
3 changed files with 31 additions and 31 deletions

View File

@ -27,6 +27,16 @@ module Rails
end
end
def docker_for_database_base(database = options[:database])
case database
when "mysql" then "curl default-mysql-client libvips"
when "trilogy" then "curl libvips"
when "postgresql" then "curl libvips postgresql-client"
when "sqlite3" then "curl libsqlite3-0 libvips"
else nil
end
end
def docker_for_database_build(database = options[:database])
case database
when "mysql" then "build-essential default-libmysqlclient-dev git"
@ -37,16 +47,6 @@ module Rails
end
end
def docker_for_database_deploy(database = options[:database])
case database
when "mysql" then "curl default-mysql-client libvips"
when "trilogy" then "curl libvips"
when "postgresql" then "curl libvips postgresql-client"
when "sqlite3" then "curl libsqlite3-0 libvips"
else nil
end
end
def convert_database_option_for_jruby
if defined?(JRUBY_VERSION)
opt = options.dup
@ -59,14 +59,6 @@ module Rails
end
end
def build_package_for_database(database = options[:database])
case database
when "mysql" then "default-libmysqlclient-dev"
when "postgresql" then "libpq-dev"
else nil
end
end
def base_package_for_database(database = options[:database])
case database
when "mysql" then "default-mysql-client"
@ -76,6 +68,14 @@ module Rails
end
end
def build_package_for_database(database = options[:database])
case database
when "mysql" then "default-libmysqlclient-dev"
when "postgresql" then "libpq-dev"
else nil
end
end
private
def mysql_socket
@mysql_socket ||= [

View File

@ -44,14 +44,14 @@ module Rails
dockerfile_path = File.expand_path("Dockerfile", destination_root)
return unless File.exist?(dockerfile_path)
base_name = docker_for_database_base
build_name = docker_for_database_build
deploy_name = docker_for_database_deploy
if base_name
gsub_file("Dockerfile", all_docker_bases_regex, base_name)
end
if build_name
gsub_file("Dockerfile", all_docker_builds_regex, build_name)
end
if deploy_name
gsub_file("Dockerfile", all_docker_deploys_regex, deploy_name)
end
end
private
@ -59,12 +59,12 @@ module Rails
DATABASES.map { |database| gem_for_database(database) }
end
def all_docker_builds
DATABASES.map { |database| docker_for_database_build(database).nil? ? nil : docker_for_database_build(database) }.compact!
def all_docker_bases
DATABASES.map { |database| docker_for_database_base(database).nil? ? nil : docker_for_database_base(database) }.compact!
end
def all_docker_deploys
DATABASES.map { |database| docker_for_database_deploy(database).nil? ? nil : docker_for_database_deploy(database) }.compact!
def all_docker_builds
DATABASES.map { |database| docker_for_database_build(database).nil? ? nil : docker_for_database_build(database) }.compact!
end
def all_database_gems_regex
@ -72,12 +72,12 @@ module Rails
/(\b#{all_database_gem_names.join('\b|\b')}\b)/
end
def all_docker_builds_regex
/(\b#{all_docker_builds.join('\b|\b')}\b)/
def all_docker_bases_regex
/(\b#{all_docker_bases.join('\b|\b')}\b)/
end
def all_docker_deploys_regex
/(\b#{all_docker_deploys.join('\b|\b')}\b)/
def all_docker_builds_regex
/(\b#{all_docker_builds.join('\b|\b')}\b)/
end
def gem_entry_regex_for(gem_name)

View File

@ -85,7 +85,7 @@ module Rails
end
assert_file("Dockerfile") do |content|
assert_match "build-essential git libvips", content
assert_match "build-essential git", content
assert_match "curl libsqlite3-0 libvips", content
end
end