dockerfile-rails 1.6.6 → 1.6.8

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: ff714b723bfd0a501b2ebef7946a4d00877233cf1912d5092c7ff92d57b938ae
4
- data.tar.gz: 5ba04178d0f287466a58c8bc496583faa6f01812c58086819ec8d8e37c8190fb
3
+ metadata.gz: a58920acbac3b3f5f952ae58113b9270f1b6817d8f61faeb357de48aad49b7ba
4
+ data.tar.gz: 89b5140bc2f150a5eda54229efcc984ecac8a3466ead51ac8fb1e57f5f2b8278
5
5
  SHA512:
6
- metadata.gz: 17cc361096d9afdb32917d80701af6904395160e1e4715f4b41bdfbe707bb51c1c074d0f5b1cc3f8fbdeed6ac2ca90702721d844ed65ede457144eab820b863d
7
- data.tar.gz: b2af2f207fa347f4b90a9fe09cfe7466702ffdce144e40d1f618049be00ab64fdf577b067111635ee46593d6bd1e5aacd80061770e950846a3c426b8bb5fbdef
6
+ metadata.gz: 77b12d5c786818fe06fcc7e931fd525d5737b4e7cfcf8a28c30807e7492bcf2a8c71cc30aeeacae1eed0cc148d8b75cee9c8e5ba73748e2fa797bd6075389da0
7
+ data.tar.gz: 868466c5f0b09071614d0530ea529e51906967e9976832596b35bd7d130a2e7ffc57e872df6db3bd0921b855f68e886f91027555840d295c3b3aedabf01cb850
data/README.md CHANGED
@@ -51,6 +51,7 @@ different contents. If both are specified, `--force` takes precedence.
51
51
  * `--compose` - generate a `docker-compose.yml` file
52
52
  * `--max-idle=n` - exit afer *n* seconds of inactivity. Supports [iso 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) and [sleep](https://man7.org/linux/man-pages/man1/sleep.1.html#DESCRIPTION) syntaxes. Uses passenger for now, awaiting [puma](https://github.com/puma/puma/issues/2580) support.
53
53
  * `--nginx` - serve static files via [nginx](https://www.nginx.com/). May require `--root` on some targets to access `/dev/stdout`
54
+ * `--thruster` - serve static files via [thruster](https://github.com/basecamp/thruster?tab=readme-ov-file#thruster).
54
55
  * `--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.
55
56
  * `--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).
56
57
  * `--sudo` - install and configure sudo to enable `sudo -iu rails` access to full environment
@@ -127,7 +128,9 @@ Running all integration tests, or even a single individual test can be done as f
127
128
 
128
129
  ```
129
130
  rake test
130
- ruby test/test_minimal.rb
131
+
132
+ bundle exec rake test TEST=test/test_minimal.rb
133
+ bundle exec ruby test/test_minimal.rb
131
134
  ```
132
135
 
133
136
  To assist with this process, outputs of tests can be captured automatically. This is useful when adding new tests and when making a change that affects many tests. Be sure to inspect the output (e.g., by using `git diff`) before committing.
@@ -40,6 +40,7 @@ class DockerfileGenerator < Rails::Generators::Base
40
40
  "sentry" => false,
41
41
  "sudo" => false,
42
42
  "swap" => nil,
43
+ "thruster" => false,
43
44
  "variant" => nil,
44
45
  "windows" => false,
45
46
  "yjit" => false,
@@ -185,6 +186,9 @@ class DockerfileGenerator < Rails::Generators::Base
185
186
  class_option :label, type: :hash, default: {},
186
187
  desc: "Add Docker label(s)"
187
188
 
189
+ class_option :thruster, type: :boolean, default: OPTION_DEFAULTS.thruster,
190
+ desc: "use Thruster HTTP/2 proxy"
191
+
188
192
  class_option :nginx, type: :boolean, default: OPTION_DEFAULTS.nginx,
189
193
  desc: "Serve static files with nginx"
190
194
 
@@ -507,6 +511,10 @@ private
507
511
  system "bundle add sentry-rails --skip-install" unless @gemfile.include? "sentry-rails"
508
512
  end
509
513
 
514
+ if options.thruster?
515
+ system "bundle add thruster --skip-install" unless @gemfile.include? "thruster"
516
+ end
517
+
510
518
  if options.rollbar?
511
519
  system "bundle add rollbar --skip-install" unless @gemfile.include? "rollbar"
512
520
  end
@@ -1026,6 +1034,8 @@ private
1026
1034
  end
1027
1035
 
1028
1036
  def node_version
1037
+ return unless using_node? || using_execjs?
1038
+
1029
1039
  version = nil
1030
1040
 
1031
1041
  if File.exist? ".node-version"
@@ -1126,6 +1136,10 @@ private
1126
1136
  nginx: '/usr/sbin/nginx -g "daemon off;"',
1127
1137
  rails: "./bin/rails server -p 3001"
1128
1138
  }
1139
+ elsif options.thruster? || @gemfile.include?("thruster")
1140
+ {
1141
+ rails: "bundle exec thrust ./bin/rails server"
1142
+ }
1129
1143
  else
1130
1144
  {
1131
1145
  rails: "./bin/rails server"
@@ -1249,7 +1263,7 @@ private
1249
1263
  list.map { |name, cmd| " #{name} = #{cmd.inspect}" }.join("\n") + '\1')
1250
1264
  else
1251
1265
  toml += "\n[processes]\n" +
1252
- list.map { |name, cmd| " #{name} = #{cmd.inspect}\n" }.join
1266
+ list.map { |name, cmd| " #{name} = #{cmd.inspect}\n" }.join + "\n"
1253
1267
 
1254
1268
  app = list.has_key?("app") ? "app" : list.keys.first
1255
1269
 
@@ -1291,7 +1305,19 @@ private
1291
1305
 
1292
1306
  if match
1293
1307
  size = ((match[1].to_i * (suffixes[match[2]] || 1)) / 1048576.0).round
1294
- toml += "swap_size_mb = #{size}"
1308
+ if toml.include? "swap_size_mb"
1309
+ toml.sub!(/swap_size_mb.*/, "swap_size_mb = #{size}")
1310
+ else
1311
+ toml += "swap_size_mb = #{size}\n\n"
1312
+ end
1313
+ end
1314
+ end
1315
+
1316
+ # Add statics if not already present and not using a web server and workdir doesn't contain a variable
1317
+ unless options.nginx? || using_passenger? || options.thruster? || @gemfile.include?("thruster")
1318
+ workdir = (IO.read "Dockerfile" rescue "").scan(/^\s*WORKDIR\s+(\S+)/).flatten.last
1319
+ unless workdir && !workdir.include?("$") && toml.include?("[statics]")
1320
+ toml += "[[statics]]\n guest_path = \"#{workdir}/public\"\n url_prefix = \"/\"\n\n"
1295
1321
  end
1296
1322
  end
1297
1323
 
@@ -286,7 +286,11 @@ ENV <%= deploy_env.join(" \\\n ") %>
286
286
  <% else -%>
287
287
  # Entrypoint sets up the container.
288
288
  <% end -%>
289
+ <% if using_litefs? -%>
290
+ ENTRYPOINT ["litefs", "mount"]
291
+ <% else -%>
289
292
  ENTRYPOINT ["/rails/bin/docker-entrypoint"]
293
+ <% end -%>
290
294
 
291
295
  <% if procfile.size > 1 -%>
292
296
  # Build a Procfile for production use
@@ -307,7 +311,7 @@ VOLUME /data
307
311
  CMD ["foreman", "start", "--procfile=<%= options.procfile %>"]
308
312
  <% elsif procfile.size > 1 -%>
309
313
  CMD ["foreman", "start", "--procfile=Procfile.prod"]
310
- <% else -%>
314
+ <% elsif !using_litefs? -%>
311
315
  CMD <%= procfile.values.first.split(" ").inspect %>
312
316
  <% end -%>
313
317
  <% end -%>
@@ -77,6 +77,8 @@ proxy:
77
77
  # "static" which assigns a single node to be the primary and does
78
78
  # not failover.
79
79
  lease:
80
+ promote: true
81
+
80
82
  # Required. Must be either "consul" or "static".
81
83
  type: "consul"
82
84
 
@@ -114,3 +116,19 @@ lease:
114
116
  # can become leader. This buffer is intended to prevent
115
117
  # overlap in leadership due to clock skew or in-flight calls.
116
118
  lock-delay: "1s"
119
+
120
+ exec:
121
+ # Only run migrations on candidate nodes.
122
+ - cmd: "./bin/rails db:prepare"
123
+ if-candidate: true
124
+
125
+ # Then run the application server on all nodes.
126
+ <% if !options.procfile.blank? -%>
127
+ - cmd: "foreman start --procfile=<%= options.procfile %>"
128
+ <% elsif procfile.size > 1 -%>
129
+ - cmd: "foreman start --procfile=Procfile.prod"
130
+ <% elsif !using_litefs? -%>
131
+ - cmd: <%= procfile.values.first.split(" ").inspect %>
132
+ <% else -%>
133
+ - cmd: "./bin/rails server"
134
+ <% 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.6.6
4
+ version: 1.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-03 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails