Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Thruster by default to Rails 8 #51793

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
50a0a92
Allow docker entrypoint script to have other preceeding commands in C…
dhh May 12, 2024
6802efc
Add Thruster by default
dhh May 12, 2024
af6a46a
Include new binstub
dhh May 12, 2024
a7735e1
Temporarily expose only 80 (via 3000)
dhh May 12, 2024
0db4997
Just expose 80 for now, Kamal will need to handle 443
dhh May 13, 2024
761361c
Correct typo in activerecord changelog [ci skip]
sampatbadhe May 12, 2024
85d67a1
Defer route drawing to the first request, or when url_helpers called.
gmcgibbon Apr 2, 2024
b3bb3e9
Support `touch_all` in batches
fatkodima May 11, 2024
650c147
Do not trigger devcontainer tests on pull requests
rafaelfranca May 13, 2024
f332c85
Refactor `ActiveRecord::SignedId` to not rely on relation delegation
byroot May 13, 2024
873b167
Refactor `ActiveRecord::TokenFor` to not rely on relation delegation
byroot May 13, 2024
4b51f4b
Fix: batch test assertion order
akhilgkrishnan May 13, 2024
b1381c3
Move `ActiveRecord::Base.delete` in `Relation`
byroot May 13, 2024
565b348
Move `ActiveRecord::Base.destroy` in `Relation`
byroot May 13, 2024
5624c4e
Move `ActiveRecord::Base.insert` in `Relation`
byroot May 13, 2024
18e883c
Use `foreign_key` option for destroy_async test models
yahonda May 13, 2024
e945213
Suppress RuboCop output when there are no offenses in code generation
koic May 12, 2024
1f41614
Enable Lint/Debugger
zzak May 13, 2024
6be45d2
Support `duration` in `ActiveSupport::XmlMini`
heka1024 Apr 24, 2024
0479dbf
Development of Rails 8.0 starts now
rafaelfranca May 13, 2024
e299811
Reapply "Rails 8 will target Ruby 3.3+ only for new apps"
rafaelfranca May 13, 2024
73bf2ab
Clean CHANGELOG for 8.0
rafaelfranca May 13, 2024
9b549ae
Fix rubocop
rafaelfranca May 13, 2024
8e21c38
Add name to DevContainer compose file
duduribeiro May 11, 2024
3d7b31d
Remove support for oracle, sqlserver and JRuby specific database adap…
andrewn617 May 13, 2024
2a0b865
Refactoring Database generators
andrewn617 May 8, 2024
d4785f9
This will be released in 7.2
rafaelfranca May 13, 2024
7317d1d
Merge pull request #51766 from Shopify/revert-actionable-errors-retry
rafaelfranca May 13, 2024
b8ab802
Point user to devcontainer for containerized dev environment
andrewn617 May 11, 2024
9c4461b
Add Highlights section in the Rails 7.1 release notes
rafaelfranca May 13, 2024
5a620d8
Fix `ActiveRecord::Relation#touch_all` with custom attribute aliased …
fatkodima May 11, 2024
68f6172
Remove jruby and oracle related gems from Gemfile
rafaelfranca May 13, 2024
b4ff621
Add Kamal by default to Rails 8 (#51798)
dhh May 14, 2024
667a415
Merge branch 'main' into thrust-by-default
dhh May 14, 2024
39c06bf
Excess CR
dhh May 14, 2024
c67f4b1
Merge branch 'main' into thrust-by-default
dhh May 14, 2024
9753adc
Add Thruster for testing
dhh May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def self.add_shared_options_for(name)
class_option :skip_dev_gems, type: :boolean, default: nil,
desc: "Skip development gems (e.g., web-console)"

class_option :skip_thruster, type: :boolean, default: nil,
desc: "Skip Thruster setup"

class_option :skip_rubocop, type: :boolean, default: nil,
desc: "Skip RuboCop setup"

Expand Down Expand Up @@ -394,6 +397,10 @@ def skip_propshaft?
skip_asset_pipeline? || options[:asset_pipeline] != "propshaft"
end

def skip_thruster?
options[:skip_thruster]
end

def skip_rubocop?
options[:skip_rubocop]
end
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/rails/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def app
end

def bin
exclude_pattern = Regexp.union([(/rubocop/ if skip_rubocop?), (/brakeman/ if skip_brakeman?)].compact)
exclude_pattern = Regexp.union([(/thrust/ if skip_thruster?), (/rubocop/ if skip_rubocop?), (/brakeman/ if skip_brakeman?)].compact)
directory "bin", { exclude_pattern: exclude_pattern } do |content|
"#{shebang}\n" + content
end
Expand Down
12 changes: 10 additions & 2 deletions railties/lib/rails/generators/rails/app/templates/Dockerfile.tt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# syntax = docker/dockerfile:1

# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t my-app .
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
# docker build -t <%= app_name %> .
# docker run -d -p 80:<%= skip_thruster? ? 3000 : 80 %> -e RAILS_MASTER_KEY=<value from config/master.key> --name <%= app_name %> <%= app_name %>

# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html

# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html

Expand Down Expand Up @@ -107,6 +109,12 @@ USER 1000:1000
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

<% if skip_thruster? -%>
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]
<% else -%>
# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
<% end -%>
5 changes: 5 additions & 0 deletions railties/lib/rails/generators/rails/app/templates/Gemfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ gem "bootsnap", require: false
# Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
gem "kamal", require: false
<% end -%>
<% unless options.skip_thruster? -%>

# Add HTTP/2, HTTP asset caching/compression, Let's Encrypt auto-certificates to Puma [https://github.com/basecamp/thruster/]
gem "thruster", require: false
dhh marked this conversation as resolved.
Show resolved Hide resolved
<% end -%>
<% unless skip_active_storage? -%>

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
Expand Down
rafaelfranca marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require "rubygems"
require "bundler/setup"

load Gem.bin_path("thruster", "thrust")
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

<% unless skip_active_record? -%>
# If running the rails server then create or migrate existing database
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
./bin/rails db:prepare
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test
def generate_test_dummy(force = false)
opts = options.transform_keys(&:to_sym).except(*DUMMY_IGNORE_OPTIONS)
opts[:force] = force
opts[:skip_thruster] = true
opts[:skip_brakeman] = true
opts[:skip_bundle] = true
opts[:skip_ci] = true
Expand Down
13 changes: 13 additions & 0 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
bin/rake
bin/rubocop
bin/setup
bin/thrust
config.ru
config/application.rb
config/boot.rb
Expand Down Expand Up @@ -605,6 +606,18 @@ def test_inclusion_of_a_debugger
end
end

def test_inclusion_of_thruster
run_generator
assert_gem "thruster"
end

def test_thruster_is_skipped_if_required
run_generator [destination_root, "--skip-thruster"]

assert_no_gem "thruster"
assert_no_file "bin/thrust"
end

def test_inclusion_of_rubocop
run_generator
assert_gem "rubocop-rails-omakase"
Expand Down
Loading