dockerfile-rails 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1aca228134c031de432e9c059c2451da36827f11334c25498506e1dc1a5f7819
4
- data.tar.gz: b661bfc9e1d9a3aafa0a10181a33927616e06162bb4ea24f960d33ff5598337c
3
+ metadata.gz: d8ce323b4347b43694278ab3b78c36c300deef6c88acff15e3a5c6e66ef5a0ad
4
+ data.tar.gz: 507e7a76e5f38761f3d729b665d93f231185ffc07edd3665ca88a034244a1dc3
5
5
  SHA512:
6
- metadata.gz: b432aedcdafad7b3aea076ad4501252aa2dc51f3cd980be1e6d4761d43b57773ec76ebc862d4f9cdd8526f1d5e3cf77c5f24b48d615fe558e0055b54aabd0803
7
- data.tar.gz: c20b0900280252cef4eab686b3f0b2718e99e46779504174fd4898d86ec68868607acc1cc5179d5c815334c2d911e0bd587169dfe6ca023af40e2caa743f66fc
6
+ metadata.gz: d9d99879f76d1e9d1e4f601db989b5d6a80e3b4113456827e2b0ab17a495163fb14925c6a6ea34ed760f2921fe482ccfc377e89382e40c10681d3423da6c3f16
7
+ data.tar.gz: 40a0a469845941a12367aa5f1a7e54f7834a8b07ac081b9bdcf922d30c57d02d75dc994c7b6d1c77e301fac2142e7dcac29551b443286a9c51342582ac043aaa
data/README.md CHANGED
@@ -44,6 +44,7 @@ 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
47
48
  * `--sudo` - install and configure sudo to enable `sudo -iu rails` access to full environment
48
49
 
49
50
  ### Add a Database:
@@ -33,6 +33,7 @@ class DockerfileGenerator < Rails::Generators::Base
33
33
  "registry" => "",
34
34
  "root" => false,
35
35
  "sqlite3" => false,
36
+ "sentry" => false,
36
37
  "sudo" => false,
37
38
  "swap" => nil,
38
39
  "variant" => "slim",
@@ -169,6 +170,9 @@ class DockerfileGenerator < Rails::Generators::Base
169
170
  class_option :sudo, type: :boolean, default: OPTION_DEFAULTS.sudo,
170
171
  desc: "Install and configure sudo to enable running as rails with full environment"
171
172
 
173
+ class_option :sentry, type: :boolean, default: OPTION_DEFAULTS.sentry,
174
+ desc: "Install gems and a starter initializer for sentry"
175
+
172
176
  class_option "migrate", type: :string, default: OPTION_DEFAULTS.migrate,
173
177
  desc: "custom migration/db:prepare script"
174
178
 
@@ -282,7 +286,7 @@ class DockerfileGenerator < Rails::Generators::Base
282
286
  fly_attach_consul
283
287
  end
284
288
 
285
- if File.exist?("fly.toml") && (fly_processes || !options.prepare)
289
+ if File.exist?("fly.toml") && (fly_processes || !options.prepare || options.swap)
286
290
  if File.stat("fly.toml").size > 0
287
291
  template "fly.toml.erb", "fly.toml"
288
292
  else
@@ -291,6 +295,10 @@ class DockerfileGenerator < Rails::Generators::Base
291
295
  end
292
296
  end
293
297
 
298
+ if options.sentry? && (not File.exist?("config/initializers/sentry.rb"))
299
+ template "sentry.rb.erb", "config/initializers/sentry.rb"
300
+ end
301
+
294
302
  if @gemfile.include?("vite_ruby")
295
303
  package = JSON.load_file("package.json")
296
304
  unless package.dig("scripts", "build")
@@ -432,6 +440,11 @@ private
432
440
  system "bundle add redis --skip-install" unless @gemfile.include? "redis"
433
441
  end
434
442
 
443
+ if options.sentry?
444
+ system "bundle add sentry-ruby --skip-install" unless @gemfile.include? "sentry-ruby"
445
+ system "bundle add sentry-rails --skip-install" unless @gemfile.include? "sentry-rails"
446
+ end
447
+
435
448
  # https://stackoverflow.com/questions/70500220/rails-7-ruby-3-1-loaderror-cannot-load-such-file-net-smtp/70500221#70500221
436
449
  if @gemfile.include? "mail"
437
450
  %w(net-smtp net-imap net-pop).each do |gem|
@@ -644,7 +657,7 @@ private
644
657
  repos += [
645
658
  "curl https://dl-ssl.google.com/linux/linux_signing_key.pub |",
646
659
  " gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&",
647
- 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
660
+ 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
648
661
  ]
649
662
  end
650
663
 
@@ -723,12 +736,7 @@ private
723
736
  end
724
737
 
725
738
  if options.jemalloc? && !options.fullstaq?
726
- if (options.platform || Gem::Platform.local.cpu).include? "arm"
727
- env["LD_PRELOAD"] = "/usr/lib/aarch64-linux-gnu/libjemalloc.so.2"
728
- else
729
- env["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
730
- end
731
-
739
+ env["LD_PRELOAD"] = "libjemalloc.so.2"
732
740
  env["MALLOC_CONF"] = "dirty_decay_ms:1000,narenas:2,background_thread:true"
733
741
  end
734
742
 
@@ -1078,6 +1086,29 @@ private
1078
1086
  end
1079
1087
  end
1080
1088
 
1089
+ if options.swap
1090
+ suffixes = {
1091
+ "kib" => 1024,
1092
+ "k" => 1024,
1093
+ "kb" => 1000,
1094
+ "mib" => 1048576,
1095
+ "m" => 1048576,
1096
+ "mb" => 100000,
1097
+ "gib" => 1073741824,
1098
+ "g" => 1073741824,
1099
+ "gb" => 100000000,
1100
+ }
1101
+
1102
+ pattern = Regexp.new("^(\\d+)(#{suffixes.keys.join('|')})?$", "i")
1103
+
1104
+ match = pattern.match(options.swap.downcase)
1105
+
1106
+ if match
1107
+ size = ((match[1].to_i * (suffixes[match[2]] || 1)) / 1048576.0).round
1108
+ toml += "swap_size_mb = #{size}"
1109
+ end
1110
+ end
1111
+
1081
1112
  toml
1082
1113
  end
1083
1114
  end
@@ -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 \/dev\/stdout;/' /etc/nginx/nginx.conf && \
7
- sed -i 's/error_log\s.*;/error_log \/dev\/stderr info;/' /etc/nginx/nginx.conf
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
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 /dev/stdout;
13
+ access_log stdout;
14
14
 
15
15
  root /rails/public;
16
16
 
@@ -20,10 +20,10 @@ EOF
20
20
  <% end -%>
21
21
  EOF
22
22
  RUN echo "daemon off;" >> /etc/nginx/nginx.conf && \
23
- sed -i 's/access_log\s.*;/access_log \/dev\/stdout;/' /etc/nginx/nginx.conf && \
24
- sed -i 's/error_log\s.*;/error_log \/dev\/stderr info;/' /etc/nginx/nginx.conf && \
23
+ sed -i 's/access_log\s.*;/access_log stdout;/' /etc/nginx/nginx.conf && \
24
+ sed -i 's/error_log\s.*;/error_log stderr info;/' /etc/nginx/nginx.conf && \
25
25
  <% if options['max-idle'] -%>
26
26
  chmod +sx /etc/nginx/sites-enabled/hook_detached_process && \
27
27
  <% end -%>
28
28
  sed -i 's/user www-data/user rails/' /etc/nginx/nginx.conf && \
29
- mkdir /var/run/passenger-instreg
29
+ mkdir /var/run/passenger-instreg
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash -e
2
2
 
3
- <% if options.swap -%>
3
+ <% if options.swap && !File.exist?("fly.toml")-%>
4
4
  <% if run_as_root? or using_passenger? -%>
5
5
  <% @space = "" -%>
6
6
  <% else -%>
@@ -0,0 +1,13 @@
1
+ Sentry.init do |config|
2
+ config.dsn = ENV["SENTRY_DSN"]
3
+ config.breadcrumbs_logger = [:active_support_logger, :http_logger]
4
+
5
+ # Set traces_sample_rate to 1.0 to capture 100%
6
+ # of transactions for performance monitoring.
7
+ # We recommend adjusting this value in production.
8
+ config.traces_sample_rate = 1.0
9
+ # or
10
+ config.traces_sampler = lambda do |context|
11
+ true
12
+ end
13
+ 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.1
4
+ version: 1.5.2
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-01 00:00:00.000000000 Z
11
+ date: 2023-07-24 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/sentry.rb.erb
55
56
  homepage: https://github.com/fly-apps/dockerfile-rails
56
57
  licenses:
57
58
  - MIT