diff --git a/lib/generators/dockerfile_generator.rb b/lib/generators/dockerfile_generator.rb index 58a8fe5..bdb10af 100644 --- a/lib/generators/dockerfile_generator.rb +++ b/lib/generators/dockerfile_generator.rb @@ -438,8 +438,8 @@ def generate_app 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") + if !toml.include?("[env]") + toml += "\n[env]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") File.write "fly.toml", toml end end @@ -1444,18 +1444,34 @@ def configure_tigris def fly_make_toml toml = File.read("fly.toml") + dockerfile = File.read("Dockerfile") rescue "" list = fly_processes if list + env = {} + if using_thruster? primary = list.keys.first list[primary] = list[primary].sub(/^.*thrust /, "") - env = { "PORT" => "8080" } + env["PORT"] = "8080" + end - if !toml.include?("[[env]]") - toml += "\n[[env]]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") + "\n" - end + 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" + env["PORT"] = "8080" + end + + if solidq_launcher == :env && !dockerfile.include?("SOLID_QUEUE_IN_PUMA") + env["SOLID_QUEUE_IN_PUMA"] = "true" + end + + unless env.empty? || toml.include?("[env]") + toml += "\n[env]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") + "\n" end if toml.include? "[processes]" diff --git a/test/results/no_prep/fly.toml b/test/results/no_prep/fly.toml index 5898028..8d44985 100644 --- a/test/results/no_prep/fly.toml +++ b/test/results/no_prep/fly.toml @@ -1,5 +1,5 @@ -[[env]] +[env] PORT = "8080" [processes] diff --git a/test/results/sidekiq/fly.toml b/test/results/sidekiq/fly.toml index a151557..311a45e 100644 --- a/test/results/sidekiq/fly.toml +++ b/test/results/sidekiq/fly.toml @@ -1,5 +1,5 @@ -[[env]] +[env] PORT = "8080" [processes] diff --git a/test/results/solid_queue_postgres/fly.toml b/test/results/solid_queue_postgres/fly.toml index 84fcac1..dcca531 100644 --- a/test/results/solid_queue_postgres/fly.toml +++ b/test/results/solid_queue_postgres/fly.toml @@ -1,5 +1,5 @@ -[[env]] +[env] PORT = "8080" [processes] diff --git a/test/results/sqlite3/fly.toml b/test/results/sqlite3/fly.toml index f971ee7..fc497e6 100644 --- a/test/results/sqlite3/fly.toml +++ b/test/results/sqlite3/fly.toml @@ -1,5 +1,5 @@ -[[env]] +[env] PORT = "8080" [processes]