dockerfile-rails 1.5.11 → 1.5.14

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: 1d82a193aafa58b460153c6f40f11eb3ef6928dd889b2225cf05c8d54403413e
4
- data.tar.gz: 102a8194647678ee4d21cbdc5e01aeab3f626a6498ae8b01bc1ec1f9ab8e25ae
3
+ metadata.gz: 0fe17ee50b4f27de006bd75e0c810a0dcc0340676c79888729039e2bce7394d3
4
+ data.tar.gz: 135cf712dcd44282a8255460288045078450fe809dd24413aa510eb2a5505a69
5
5
  SHA512:
6
- metadata.gz: f9eeb2d4615acba7c25d796b7c77cf636794b73e003f966c061607e5c46948db96c84c42d3cc4608ad2afbdcae8ebb13f580dfac971e5318d232190b983d8eb0
7
- data.tar.gz: 4f94cb176f2d6bb93379895cc5616d93061638c2f5ec17af50492d397007d8457f90adc14851e0bde6c8d95a1ccb5f57294466fddd19169f29b3ef8db43201b2
6
+ metadata.gz: 152a64e964d12c90dd9f723cfcc5a22f8676eca1aed835de5f829fb851b67075521115eeb24d5f72f4ec2482954a4bc3739c5f9f0b3594a167bf05af65f3da80
7
+ data.tar.gz: 76579f910905786f5b1c38320f3efce47accebd5d3e829a16e6cec5aa3a32ac609a3b9c4137f66f4d299ed3b32c4acda9643db32f1ac0825b187c501bea1cfdf
data/README.md CHANGED
@@ -22,7 +22,7 @@ bundle add dockerfile-rails --optimistic --group development
22
22
  bin/rails generate dockerfile
23
23
  ```
24
24
 
25
- The `--optomistic` flag will make sure you always get the latest `dockerfile-rails` gem when you run `bundle update && rails g dockerfile`.
25
+ The `--optimistic` flag will make sure you always get the latest `dockerfile-rails` gem when you run `bundle update && rails g dockerfile`.
26
26
 
27
27
  ### General option:
28
28
 
@@ -880,8 +880,9 @@ private
880
880
  end
881
881
 
882
882
  def binfile_fixups
883
+ binfiles = Dir["bin/*"].select { |f| File.file?(f) }
883
884
  # binfiles may have OS specific paths to ruby. Normalize them.
884
- shebangs = Dir["bin/*"].map do |file|
885
+ shebangs = binfiles.map do |file|
885
886
  IO.read(file).lines.first.encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "")
886
887
  end.join
887
888
  rubies = shebangs.scan(%r{#!/usr/bin/env (ruby.*)}).flatten.uniq
@@ -896,14 +897,14 @@ private
896
897
  # line endings. This avoids adding unnecessary fixups if
897
898
  # none are required, but prepares for the need to do the
898
899
  # fix line endings if other fixups are required.
899
- has_cr = Dir["bin/*"].any? { |file| IO.read(file).include? "\r" }
900
+ has_cr = binfiles.any? { |file| IO.read(file).include? "\r" }
900
901
  if has_cr || (Gem.win_platform? && !binfixups.empty?) || options.windows?
901
902
  binfixups.unshift 'sed -i "s/\r$//g" bin/*'
902
903
  end
903
904
 
904
905
  # Windows file systems may not have the concept of executable.
905
906
  # In such cases, fix up during the build.
906
- if Dir["bin/*"].any? { |file| !File.executable?(file) } || options.windows?
907
+ if binfiles.any? { |file| !File.executable?(file) } || options.windows?
907
908
  binfixups.unshift "chmod +x bin/*"
908
909
  end
909
910
 
@@ -1107,12 +1108,17 @@ private
1107
1108
  return unless toml.include?("primary_region") # v2
1108
1109
 
1109
1110
  # see if flyctl is in the path
1110
- paths = ENV["PATH"].split(File::PATH_SEPARATOR)
1111
- cmds = %w(flyctl)
1112
- exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
1113
- flyctl = Enumerator.product(paths, cmds, exts).
1114
- map { |path, cmd, ext| File.join(path, "#{cmd}#{ext}") }.
1115
- find { |path| File.executable? path }
1111
+ flyctl = (lambda do
1112
+ cmd = "flyctl"
1113
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
1114
+ (ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]).each do |ext|
1115
+ path = File.join(path, "#{cmd}#{ext}")
1116
+ return path if File.executable? path
1117
+ end
1118
+ end
1119
+
1120
+ nil
1121
+ end).call
1116
1122
  return unless flyctl
1117
1123
 
1118
1124
  # see if secret is already set?
@@ -222,27 +222,30 @@ RUN mkdir /data
222
222
  <% else -%>
223
223
  # Run and own only the runtime files as a non-root user for security
224
224
  <% if options.compose? -%>
225
+ <% user = "rails:rails" -%>
225
226
  ARG UID=1000 \
226
227
  GID=1000
227
228
  RUN groupadd -f -g $GID rails && \
228
229
  useradd -u $UID -g $GID rails --create-home --shell /bin/bash && \
229
230
  <% else -%>
230
- RUN useradd rails --create-home --shell /bin/bash && \
231
+ <% user = "1000:1000" -%>
232
+ RUN groupadd --system --gid 1000 rails && \
233
+ useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
231
234
  <% end -%>
232
235
  <% if options.nginx? -%>
233
- chown rails:rails /var/lib/nginx /var/log/nginx/* && \
236
+ chown <%= user %> /var/lib/nginx /var/log/nginx/* && \
234
237
  <% end -%>
235
238
  <% if deploy_packages.include?("sudo") && options.sudo? -%>
236
239
  sed -i 's/env_reset/env_keep="*"/' /etc/sudoers && \
237
240
  <% end -%>
238
241
  <% if deploy_database == 'sqlite3' -%>
239
242
  mkdir /data<% if using_litefs? %> /litefs<% end %> && \
240
- chown -R rails:rails <%= Dir[*%w(db log storage tmp)].join(" ") %> /data<% if using_litefs? %> /litefs<% end %>
243
+ chown -R <%= user %> <%= Dir[*%w(db log storage tmp)].join(" ") %> /data<% if using_litefs? %> /litefs<% end %>
241
244
  <% else -%>
242
- chown -R rails:rails <%= Dir[*%w(db log storage tmp)].join(" ") %>
245
+ chown -R <%= user %> <%= Dir[*%w(db log storage tmp)].join(" ") %>
243
246
  <% end -%>
244
247
  <% unless options.swap? or using_passenger? or using_litefs? -%>
245
- USER rails:rails
248
+ USER <%= user %>
246
249
  <% end -%>
247
250
 
248
251
  <% end -%>
@@ -8,7 +8,7 @@ RUN <% if options.cache? %>--mount=type=cache,id=bld-bun-cache,target=/root/.bun
8
8
  <% end %>bun install<% if options.lock? %> --frozen-lockfile<% end %>
9
9
  <% elsif sources.join.include? 'yarn' -%>
10
10
  RUN <% if options.cache? %>--mount=type=cache,id=bld-yarn-cache,target=/root/.yarn \
11
- YARN_CACHE_FOLDER=/root/.yarn <% end %>yarn install<% if options.lock? %> --frozen-lockfile<% end %>
11
+ YARN_CACHE_FOLDER=/root/.yarn <% end %>yarn install<% if options.lock? %> --<% if yarn_version < '2' -%>frozen-lockfile<% else %>immutable<% end %><% end %>
12
12
  <% else -%>
13
13
  RUN <% if options.cache? %>--mount=type=cache,id=bld-npm-cache,target=/root/.npm \
14
14
  <% end %>npm install
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.11
4
+ version: 1.5.14
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-10-22 00:00:00.000000000 Z
11
+ date: 2023-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.4.8
77
+ rubygems_version: 3.4.10
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Dockerfile generator for Rails