lib/generators/dockerfile_generator.rb in dockerfile-rails-1.6.20 vs lib/generators/dockerfile_generator.rb in dockerfile-rails-1.6.21
- old
+ new
@@ -329,11 +329,14 @@
template "docker-entrypoint.erb", "bin/docker-entrypoint"
chmod "bin/docker-entrypoint", 0755 & ~File.umask, verbose: false
template "docker-compose.yml.erb", "docker-compose.yml" if options.compose
- template "database.yml.erb", "config/database.yml" if fix_database_config
+ if fix_database_config
+ template "database.yml.erb", "config/database.yml",
+ force: File.exist?("fly.toml")
+ end
if using_litefs?
template "litefs.yml.erb", "config/litefs.yml"
fly_attach_consul
@@ -411,14 +414,26 @@
STDERR.puts "Change your Ruby version, or run `bin/rails generate dockerfile`,"
STDERR.puts "or add the following to your Dockerfile:"
STDERR.puts 'RUN sed -i "/net-pop (0.1.2)/a\ net-protocol" Gemfile.lock'
end
- if (options.sqlite3? || @sqlite3) && !dockerfile.include?("DATABASE_URL") && File.exist?("fly.toml")
- toml = IO.read("fly.toml")
- if !toml.include?("[[env]]")
- toml += "\n[[env]]\n DATABASE_URL = \"sqlite3:///data/production.sqlite3\"\n"
- File.write "fly.toml", toml
+ if File.exist?("fly.toml")
+ env = {}
+
+ if (options.sqlite3? || @sqlite3) && !dockerfile.include?("DATABASE_URL")
+ env["DATABASE_URL"] = "sqlite3:///data/production.sqlite3"
+ end
+
+ if using_thruster? && !dockerfile.include?("HTTP_PORT")
+ env["HTTP_PORT"] = "8080"
+ end
+
+ unless env.empty?
+ toml = IO.read("fly.toml")
+ if !toml.include?("[[env]]")
+ toml += "\n[[env]]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n")
+ File.write "fly.toml", toml
+ end
end
end
exit 42 if message
end