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

Serve files with Thruster #2069

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ENV PORT=3214
ENV RACK_ENV=production
ENV RAILS_ENV=production
ENV NODE_ENV=production
ENV RAILS_SERVE_STATIC_FILES=true
ENV APP_VERSION=${APP_VERSION}
ENV GIT_SHA=${GIT_SHA}

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ gem "sidekiq-failures", "~> 1.0"
gem "activejob-status", "~> 1.0"

gem "brakeman", "~> 6.1"
gem "thruster", "~> 0.1.3"
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
text (1.3.1)
thor (1.3.1)
thruster (0.1.3)
thruster (0.1.3-x86_64-darwin)
thruster (0.1.3-x86_64-linux)
tilt (2.0.10)
timeout (0.4.1)
translation (1.40)
Expand Down Expand Up @@ -617,6 +620,7 @@ DEPENDENCIES
stopwords-filter2
string-similarity (~> 2.1)
sys-filesystem (~> 1.4)
thruster (~> 0.1.3)
translation (~> 1.40)
tzinfo-data
view_component (~> 3.12)
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rails: bundle exec rails server -p $PORT
rails: HTTP_PORT=$PORT bundle exec thrust rails server
worker: bundle exec sidekiq
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rails: bin/rails server -p $PORT
rails: HTTP_PORT=$PORT thrust bin/rails server
worker: bundle exec sidekiq
js: yarn build --watch
css: yarn build:css --watch
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Application < Rails::Application
# Treat pundit failures as standard "forbidden"
config.action_dispatch.rescue_responses["Pundit::NotAuthorizedError"] = :forbidden

# Enable X-Sendfile with Thruster in all environments
config.action_dispatch.x_sendfile_header = "X-Sendfile"

config.action_mailer.smtp_settings = {
address: ENV.fetch("SMTP_SERVER", nil),
user_name: ENV.fetch("SMTP_USERNAME", nil),
Expand Down
10 changes: 3 additions & 7 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Disable serving static files from the `/public` folder since
# Thruster handles this.
config.public_file_server.enabled = false

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand All @@ -33,10 +33,6 @@
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Store uploaded files on the local file system (see config/storage.yml for options).
# config.active_storage.service = :local

Expand Down
Loading