Skip to content

Commit

Permalink
NEW: Use thruster to boot application on production
Browse files Browse the repository at this point in the history
closes #1368
  • Loading branch information
gmmcal committed Dec 1, 2024
1 parent 6b9b7c0 commit bf99031
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -453,6 +458,7 @@ DEPENDENCIES
solid_cache
solid_queue
sprockets-rails
thruster
turbo-rails

RUBY VERSION
Expand Down
8 changes: 6 additions & 2 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -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 <anything> (executed on development image)
if [ "${3}" == "rails" ]; then
./bin/rails db:prepare
Expand Down
1 change: 0 additions & 1 deletion config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ proxy:
hosts:
- gustavocunha.dev
- www.gustavocunha.dev
app_port: 3000

registry:
username: gmmcal
Expand Down

0 comments on commit bf99031

Please sign in to comment.