Skip to content

Commit

Permalink
don't run thruster on fly.io
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Dec 11, 2024
1 parent 52b07e8 commit f157935
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
18 changes: 15 additions & 3 deletions lib/generators/dockerfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ def generate_app
env["DATABASE_URL"] = "sqlite3:///data/production.sqlite3"
end

if using_thruster? && !dockerfile.include?("HTTP_PORT")
env["HTTP_PORT"] = "8080"
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")
Expand Down Expand Up @@ -1277,7 +1278,7 @@ def using_thruster?

def fly_processes
return unless File.exist? "fly.toml"
return unless using_sidekiq? || using_solidq?
return unless using_sidekiq? || using_solidq? || using_thruster?

if procfile.size > 1
list = { "app" => "foreman start --procfile=Procfile.prod" }
Expand Down Expand Up @@ -1446,6 +1447,17 @@ def fly_make_toml

list = fly_processes
if list
if using_thruster?
primary = list.keys.first
list[primary] = list[primary].sub(/^.*thrust /, "")

env = { "PORT" => "8080" }

if !toml.include?("[[env]]")
toml += "\n[[env]]\n" + env.map { |key, value| " #{key} = #{value.inspect}" }.join("\n") + "\n"
end
end

if toml.include? "[processes]"
toml.sub!(/\[processes\].*?(\n\n|\n?\z)/m, "[processes]\n" +
list.map { |name, cmd| " #{name} = #{cmd.inspect}" }.join("\n") + '\1')
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/Dockerfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ EXPOSE <%= using_thruster? ? '80' : '3000' %>
<% if deploy_database == 'sqlite3' -%>
VOLUME /data
<% end -%>
<% unless fly_processes -%>
<% unless fly_processes && !using_thruster? -%>
<% if !options.procfile.blank? -%>
CMD ["foreman", "start", "--procfile=<%= options.procfile %>"]
<% elsif procfile.size > 1 -%>
Expand Down
7 changes: 7 additions & 0 deletions test/results/no_prep/fly.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

[[env]]
PORT = "8080"

[processes]
app = "./bin/rails server"

[deploy]
release_command = "./bin/rails db:prepare"

Expand Down
1 change: 1 addition & 0 deletions test/results/sidekiq/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
5 changes: 4 additions & 1 deletion test/results/sidekiq/fly.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

[[env]]
PORT = "8080"

[processes]
app = "./bin/thrust ./bin/rails server"
app = "./bin/rails server"
sidekiq = "bundle exec sidekiq"

1 change: 1 addition & 0 deletions test/results/solid_queue_postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
5 changes: 4 additions & 1 deletion test/results/solid_queue_postgres/fly.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

[[env]]
PORT = "8080"

[processes]
app = "./bin/thrust ./bin/rails server"
app = "./bin/rails server"
solidq = "bundle exec rake solid_queue:start"

7 changes: 7 additions & 0 deletions test/results/sqlite3/fly.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

[[env]]
PORT = "8080"

[processes]
app = "./bin/rails server"

[mounts]
source="data"
destination="/data"
Expand Down

0 comments on commit f157935

Please sign in to comment.