From bf99031c2f85b18818a32adf4a78147740ac2348 Mon Sep 17 00:00:00 2001 From: Gustavo Cunha Date: Sun, 1 Dec 2024 09:13:41 +0100 Subject: [PATCH] NEW: Use thruster to boot application on production closes #1368 --- Dockerfile | 2 +- Gemfile | 1 + Gemfile.lock | 6 ++++++ bin/docker-entrypoint | 8 ++++++-- config/deploy.yml | 1 - 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91dc0559..dda1b4ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,7 +59,7 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"] # Start the server by default, this can be overwritten at runtime EXPOSE 3000 -CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] +CMD ["bin/thrust", "bundle", "exec", "puma", "-C", "config/puma.rb"] FROM production AS staging diff --git a/Gemfile b/Gemfile index a53250ce..82994415 100644 --- a/Gemfile +++ b/Gemfile @@ -69,6 +69,7 @@ group :production, :staging do # Use puma as the app server gem "puma" gem "rack-cors" + gem "thruster", require: false end gem "bcrypt" diff --git a/Gemfile.lock b/Gemfile.lock index 8080c0d0..ad9ceb8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -387,6 +387,11 @@ GEM sprockets (>= 3.0.0) stringio (3.1.2) thor (1.3.2) + thruster (0.1.9) + thruster (0.1.9-aarch64-linux) + thruster (0.1.9-arm64-darwin) + thruster (0.1.9-x86_64-darwin) + thruster (0.1.9-x86_64-linux) timeout (0.4.2) ttfunk (1.8.0) bigdecimal (~> 3.1) @@ -453,6 +458,7 @@ DEPENDENCIES solid_cache solid_queue sprockets-rails + thruster turbo-rails RUBY VERSION diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint index 47b13a02..b1238d32 100755 --- a/bin/docker-entrypoint +++ b/bin/docker-entrypoint @@ -1,12 +1,16 @@ #!/bin/bash -e -# ./bin/rails server (executed on production image) +# bundle exec puma -C config/puma.rb (executed on staging image) if [ "${3}" == "puma" ]; then - echo "booting application on staging" ./bin/rails db:migrate ./bin/rails db:seed:all fi +# bin/thrust bundle exec puma -C config/puma.rb (executed on production image) +if [ "${4}" == "puma" ]; then + ./bin/rails db:migrate +fi + # bundle exec rails (executed on development image) if [ "${3}" == "rails" ]; then ./bin/rails db:prepare diff --git a/config/deploy.yml b/config/deploy.yml index b9438c71..9f4477b6 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -17,7 +17,6 @@ proxy: hosts: - gustavocunha.dev - www.gustavocunha.dev - app_port: 3000 registry: username: gmmcal