dockerfile-rails 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8ce323b4347b43694278ab3b78c36c300deef6c88acff15e3a5c6e66ef5a0ad
4
- data.tar.gz: 507e7a76e5f38761f3d729b665d93f231185ffc07edd3665ca88a034244a1dc3
3
+ metadata.gz: b14b8dc852c4d34ae6fa48251cb680e89a9c08fe81942d336d21f18418643e38
4
+ data.tar.gz: 3d61361b94688abd9545d59a43cb22fda5fc4ecd947353a7397ee88e5cfa0b68
5
5
  SHA512:
6
- metadata.gz: d9d99879f76d1e9d1e4f601db989b5d6a80e3b4113456827e2b0ab17a495163fb14925c6a6ea34ed760f2921fe482ccfc377e89382e40c10681d3423da6c3f16
7
- data.tar.gz: 40a0a469845941a12367aa5f1a7e54f7834a8b07ac081b9bdcf922d30c57d02d75dc994c7b6d1c77e301fac2142e7dcac29551b443286a9c51342582ac043aaa
6
+ metadata.gz: becc43052f96c77dc89fa920039c43151737bfd284a8b533185e7334989506b28db8c6ab87da9748712c9c52de0cb7b344ef0308992d4306fc7b47a6be0eeac6
7
+ data.tar.gz: 11210697f2034ea5295611f7b6548cad9e5712bdd8906e0acc083edde2e35404f51c22fb2624d8e4c087c02be7319c6f71a7f76d98f5054f85d6472012767fbc
data/README.md CHANGED
@@ -44,9 +44,12 @@ bin/rails generate dockerfile
44
44
  * `--nginx` - serve static files via [nginx](https://www.nginx.com/). May require `--root` on some targets to access `/dev/stdout`
45
45
  * `--no-link` - don't add [--link](https://docs.docker.com/engine/reference/builder/#copy---link) to COPY statements. Some tools (like at the moment, [buildah](https://www.redhat.com/en/topics/containers/what-is-buildah)) don't yet support this feature.
46
46
  * `--no-lock` - don't add linux platforms, set `BUNDLE_DEPLOY`, or `--frozen-lockfile`. May be needed at times to work around a [rubygems bug](https://github.com/rubygems/rubygems/issues/6082#issuecomment-1329756343).
47
- * `--sentry` -- install gems and a starter initializer for sentry
48
47
  * `--sudo` - install and configure sudo to enable `sudo -iu rails` access to full environment
49
48
 
49
+ #### Error Tracking & Alerting:
50
+ * `--rollbar` - install gem and a default initializer for [Rollbar](https://rollbar.com/#)
51
+ * `--sentry` - install gems and a default initializer for [Sentry](https://sentry.io/welcome/)
52
+
50
53
  ### Add a Database:
51
54
 
52
55
  Generally the dockerfile generator will be able to determine what dependencies you
@@ -31,6 +31,7 @@ class DockerfileGenerator < Rails::Generators::Base
31
31
  "procfile" => "",
32
32
  "redis" => false,
33
33
  "registry" => "",
34
+ "rollbar" => false,
34
35
  "root" => false,
35
36
  "sqlite3" => false,
36
37
  "sentry" => false,
@@ -171,7 +172,10 @@ class DockerfileGenerator < Rails::Generators::Base
171
172
  desc: "Install and configure sudo to enable running as rails with full environment"
172
173
 
173
174
  class_option :sentry, type: :boolean, default: OPTION_DEFAULTS.sentry,
174
- desc: "Install gems and a starter initializer for sentry"
175
+ desc: "Install gems and a default initializer for Sentry"
176
+
177
+ class_option :rollbar, type: :boolean, default: OPTION_DEFAULTS.rollbar,
178
+ desc: "Install gem and a default initializer for Rollbar"
175
179
 
176
180
  class_option "migrate", type: :string, default: OPTION_DEFAULTS.migrate,
177
181
  desc: "custom migration/db:prepare script"
@@ -299,6 +303,10 @@ class DockerfileGenerator < Rails::Generators::Base
299
303
  template "sentry.rb.erb", "config/initializers/sentry.rb"
300
304
  end
301
305
 
306
+ if options.rollbar? && (not File.exist?("config/initializers/rollbar.rb"))
307
+ template "rollbar.rb.erb", "config/initializers/rollbar.rb"
308
+ end
309
+
302
310
  if @gemfile.include?("vite_ruby")
303
311
  package = JSON.load_file("package.json")
304
312
  unless package.dig("scripts", "build")
@@ -445,6 +453,10 @@ private
445
453
  system "bundle add sentry-rails --skip-install" unless @gemfile.include? "sentry-rails"
446
454
  end
447
455
 
456
+ if options.rollbar?
457
+ system "bundle add rollbar --skip-install" unless @gemfile.include? "rollbar"
458
+ end
459
+
448
460
  # https://stackoverflow.com/questions/70500220/rails-7-ruby-3-1-loaderror-cannot-load-such-file-net-smtp/70500221#70500221
449
461
  if @gemfile.include? "mail"
450
462
  %w(net-smtp net-imap net-pop).each do |gem|
@@ -3,14 +3,14 @@ RUN gem install foreman && \
3
3
  <% unless run_as_root? -%>
4
4
  sed -i 's|pid /run|pid /rails/tmp/pids|' /etc/nginx/nginx.conf && \
5
5
  <% end -%>
6
- sed -i 's/access_log\s.*;/access_log stdout;/' /etc/nginx/nginx.conf && \
7
- sed -i 's/error_log\s.*;/error_log stderr info;/' /etc/nginx/nginx.conf
6
+ sed -i 's/access_log\s.*;/access_log <% unless run_as_root? %>\/dev\/<% end %>stdout;/' /etc/nginx/nginx.conf && \
7
+ sed -i 's/error_log\s.*;/error_log <% unless run_as_root? %>\/dev\/<% end %>stderr info;/' /etc/nginx/nginx.conf
8
8
 
9
9
  COPY <<-"EOF" /etc/nginx/sites-available/default
10
10
  server {
11
11
  listen 3000 default_server;
12
12
  listen [::]:3000 default_server;
13
- access_log stdout;
13
+ access_log <% unless run_as_root? %>/dev/<% end %>stdout;
14
14
 
15
15
  root /rails/public;
16
16
 
@@ -28,7 +28,7 @@ server {
28
28
 
29
29
  location @backend {
30
30
  proxy_pass http://localhost:3001;
31
- proxy_set_header origin 'http://localhost:3000';
31
+ proxy_set_header Host $http_host;
32
32
  }
33
33
  }
34
34
  EOF
@@ -10,6 +10,7 @@ server {
10
10
  passenger_pool_idle_time <%= max_idle %>;
11
11
  <% end -%>
12
12
  }
13
+ EOF
13
14
  <% if options['max-idle'] -%>
14
15
  COPY <<-'EOF' /etc/nginx/sites-enabled/hook_detached_process
15
16
  #!/usr/bin/env ruby
@@ -18,7 +19,6 @@ processes = status[/^Processes\s*:\s*(\d*)/, 1].to_i
18
19
  system 'nginx -s stop' if processes == 0
19
20
  EOF
20
21
  <% end -%>
21
- EOF
22
22
  RUN echo "daemon off;" >> /etc/nginx/nginx.conf && \
23
23
  sed -i 's/access_log\s.*;/access_log stdout;/' /etc/nginx/nginx.conf && \
24
24
  sed -i 's/error_log\s.*;/error_log stderr info;/' /etc/nginx/nginx.conf && \
@@ -0,0 +1,73 @@
1
+ if ENV['ROLLBAR_ENV']
2
+ Rollbar.configure do |config|
3
+ # Without configuration, Rollbar is enabled in all environments.
4
+ # To disable in specific environments, set config.enabled=false.
5
+
6
+ config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
7
+
8
+ # Here we'll disable in 'test':
9
+ if Rails.env.test?
10
+ config.enabled = false
11
+ end
12
+
13
+ # By default, Rollbar will try to call the `current_user` controller method
14
+ # to fetch the logged-in user object, and then call that object's `id`
15
+ # method to fetch this property. To customize:
16
+ # config.person_method = "my_current_user"
17
+ # config.person_id_method = "my_id"
18
+
19
+ # Additionally, you may specify the following:
20
+ # config.person_username_method = "username"
21
+ # config.person_email_method = "email"
22
+
23
+ # If you want to attach custom data to all exception and message reports,
24
+ # provide a lambda like the following. It should return a hash.
25
+ # config.custom_data_method = lambda { {:some_key => "some_value" } }
26
+
27
+ # Add exception class names to the exception_level_filters hash to
28
+ # change the level that exception is reported at. Note that if an exception
29
+ # has already been reported and logged the level will need to be changed
30
+ # via the rollbar interface.
31
+ # Valid levels: 'critical', 'error', 'warning', 'info', 'debug', 'ignore'
32
+ # 'ignore' will cause the exception to not be reported at all.
33
+ # config.exception_level_filters.merge!('MyCriticalException' => 'critical')
34
+ #
35
+ # You can also specify a callable, which will be called with the exception instance.
36
+ # config.exception_level_filters.merge!('MyCriticalException' => lambda { |e| 'critical' })
37
+
38
+ # Enable asynchronous reporting (uses girl_friday or Threading if girl_friday
39
+ # is not installed)
40
+ # config.use_async = true
41
+ # Supply your own async handler:
42
+ # config.async_handler = Proc.new { |payload|
43
+ # Thread.new { Rollbar.process_from_async_handler(payload) }
44
+ # }
45
+
46
+ # Enable asynchronous reporting (using sucker_punch)
47
+ # config.use_sucker_punch
48
+
49
+ # Enable delayed reporting (using Sidekiq)
50
+ # config.use_sidekiq
51
+ # You can supply custom Sidekiq options:
52
+ # config.use_sidekiq 'queue' => 'default'
53
+
54
+ # If your application runs behind a proxy server, you can set proxy parameters here.
55
+ # If https_proxy is set in your environment, that will be used. Settings here have precedence.
56
+ # The :host key is mandatory and must include the URL scheme (e.g. 'http://'), all other fields
57
+ # are optional.
58
+ #
59
+ # config.proxy = {
60
+ # host: 'http://some.proxy.server',
61
+ # port: 80,
62
+ # user: 'username_if_auth_required',
63
+ # password: 'password_if_auth_required'
64
+ # }
65
+
66
+ # If you run your staging application instance in production environment then
67
+ # you'll want to override the environment reported by `Rails.env` with an
68
+ # environment variable like this: `ROLLBAR_ENV=staging`. This is a recommended
69
+ # setup for Heroku. See:
70
+ # https://devcenter.heroku.com/articles/deploying-to-a-custom-rails-environment
71
+ config.environment = ENV['ROLLBAR_ENV'].presence || Rails.env
72
+ end
73
+ end
@@ -1,3 +1,5 @@
1
+ if ENV["SENTRY_DSN"]
2
+
1
3
  Sentry.init do |config|
2
4
  config.dsn = ENV["SENTRY_DSN"]
3
5
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
@@ -10,4 +12,6 @@ Sentry.init do |config|
10
12
  config.traces_sampler = lambda do |context|
11
13
  true
12
14
  end
13
- end
15
+ end
16
+
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerfile-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,7 @@ files:
52
52
  - lib/generators/templates/fly.toml.erb
53
53
  - lib/generators/templates/litefs.yml.erb
54
54
  - lib/generators/templates/node-version.erb
55
+ - lib/generators/templates/rollbar.rb.erb
55
56
  - lib/generators/templates/sentry.rb.erb
56
57
  homepage: https://github.com/fly-apps/dockerfile-rails
57
58
  licenses: