dockerfile-rails 1.2.2 → 1.2.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 +4 -4
- data/README.md +2 -1
- data/lib/generators/dockerfile_generator.rb +37 -21
- data/lib/generators/templates/Dockerfile.erb +2 -2
- data/lib/generators/templates/_npm_install.erb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98b182ee88ad6c1ba34edb41778c9d59dd329eefb6b199ede26697ded174aedb
|
4
|
+
data.tar.gz: 94e946801bc23ae53ce8ba8a4c7f8129a58e04aad1db4b9cf05bc5d43b22cebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20bb484ad3637c100cf2ff9a786404a686e961db71dbfdc1d48d0b33ea461c8031bb2ddacc05ebd3857aaa5d318fe2d49c2ecc21cd760b1fa08fac9e963a28f
|
7
|
+
data.tar.gz: 80f23221cf71777312e57165a23b93a165feae6db3af97ac8c836e71295493ff952ca34f36e2a190f392508fb0e8a92b56a42c090262076063d75b386b96be56
|
data/README.md
CHANGED
@@ -36,11 +36,12 @@ bin/rails generate dockerfile
|
|
36
36
|
* `--cache` - use build caching to speed up builds
|
37
37
|
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
|
38
38
|
|
39
|
-
### Add a Feature:
|
39
|
+
### Add/remove a Feature:
|
40
40
|
|
41
41
|
* `--ci` - include test gems in deployed image
|
42
42
|
* `--compose` - generate a `docker-compose.yml` file
|
43
43
|
* `--nginx` - serve static files via [nginx](https://www.nginx.com/). May require `--root` on some targets to access `/dev/stdout`
|
44
|
+
* `--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).
|
44
45
|
|
45
46
|
### Add a Database:
|
46
47
|
|
@@ -14,6 +14,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
14
14
|
"fullstaq" => false,
|
15
15
|
"jemalloc" => false,
|
16
16
|
"label" => {},
|
17
|
+
"lock" => true,
|
17
18
|
"mysql" => false,
|
18
19
|
"nginx" => false,
|
19
20
|
"parallel" => false,
|
@@ -67,6 +68,9 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
67
68
|
class_option :ci, type: :boolean, default: OPTION_DEFAULTS.ci,
|
68
69
|
desc: "include test gems in bundle"
|
69
70
|
|
71
|
+
class_option :lock, type: :boolean, default: OPTION_DEFAULTS.lock,
|
72
|
+
desc: "lock Gemfile/package.json"
|
73
|
+
|
70
74
|
class_option :precompile, type: :string, default: OPTION_DEFAULTS.precompile,
|
71
75
|
desc: 'if set to "defer", assets:precompile will be done at deploy time'
|
72
76
|
|
@@ -252,7 +256,7 @@ private
|
|
252
256
|
|
253
257
|
def platform
|
254
258
|
if options.platform
|
255
|
-
"--platform
|
259
|
+
"--platform=#{options.platform} "
|
256
260
|
else
|
257
261
|
""
|
258
262
|
end
|
@@ -295,32 +299,47 @@ private
|
|
295
299
|
def install_gems
|
296
300
|
ENV["BUNDLE_IGNORE_MESSAGES"] = "1"
|
297
301
|
|
302
|
+
gemfile = IO.read("Gemfile")
|
303
|
+
|
298
304
|
if options.postgresql? || @postgresql
|
299
|
-
system "bundle add pg" unless @gemfile.include? "pg"
|
305
|
+
system "bundle add pg --skip-install" unless @gemfile.include? "pg"
|
300
306
|
end
|
301
307
|
|
302
308
|
if options.mysql? || @mysql
|
303
|
-
system "bundle add mysql2" unless @gemfile.include? "mysql2"
|
309
|
+
system "bundle add mysql2 --skip-install" unless @gemfile.include? "mysql2"
|
304
310
|
end
|
305
311
|
|
306
312
|
if options.redis? || using_redis?
|
307
|
-
system "bundle add redis" unless @gemfile.include? "redis"
|
313
|
+
system "bundle add redis --skip-install" unless @gemfile.include? "redis"
|
308
314
|
end
|
309
315
|
|
310
|
-
#
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
add_platforms += ["--add-platform=x86_64-linux"]
|
316
|
+
# https://stackoverflow.com/questions/70500220/rails-7-ruby-3-1-loaderror-cannot-load-such-file-net-smtp/70500221#70500221
|
317
|
+
if @gemfile.include? "mail"
|
318
|
+
%w(net-smtp net-imap net-pop).each do |gem|
|
319
|
+
system "bundle add #{gem} --skip-install --require false" unless @gemfile.include? gem
|
320
|
+
end
|
316
321
|
end
|
317
322
|
|
318
|
-
|
319
|
-
|
323
|
+
unless gemfile == IO.read("Gemfile")
|
324
|
+
system "bundle install --quiet"
|
320
325
|
end
|
321
326
|
|
322
|
-
|
323
|
-
|
327
|
+
if options.lock?
|
328
|
+
# ensure linux platform is in the bundle lock
|
329
|
+
current_platforms = `bundle platform`
|
330
|
+
add_platforms = []
|
331
|
+
|
332
|
+
if !current_platforms.include?("x86_64-linux")
|
333
|
+
add_platforms += ["--add-platform=x86_64-linux"]
|
334
|
+
end
|
335
|
+
|
336
|
+
if !current_platforms.include?("aarch64-linux") && RUBY_PLATFORM.start_with?("arm64")
|
337
|
+
add_platforms += ["--add-platform=aarch64-linux"]
|
338
|
+
end
|
339
|
+
|
340
|
+
unless add_platforms.empty?
|
341
|
+
system "bundle lock #{add_platforms.join(" ")}"
|
342
|
+
end
|
324
343
|
end
|
325
344
|
end
|
326
345
|
|
@@ -370,9 +389,6 @@ private
|
|
370
389
|
# add git if needed to install gems
|
371
390
|
packages << "git" if @git
|
372
391
|
|
373
|
-
# add redis if Action Cable, caching, or sidekiq are used
|
374
|
-
packages << "redis" if options.redis? || using_redis?
|
375
|
-
|
376
392
|
# ActiveStorage preview support
|
377
393
|
packages << "libvips" if @gemfile.include? "ruby-vips"
|
378
394
|
|
@@ -418,9 +434,6 @@ private
|
|
418
434
|
packages << "postgresql-client" if options.postgresql? || @postgresql
|
419
435
|
packages << "default-mysql-client" if options.mysql || @mysql
|
420
436
|
|
421
|
-
# add redis in case Action Cable, caching, or sidekiq are added later
|
422
|
-
packages << "redis" if using_redis?
|
423
|
-
|
424
437
|
# ActiveStorage preview support
|
425
438
|
packages << "libvips" if @gemfile.include? "ruby-vips"
|
426
439
|
|
@@ -465,10 +478,13 @@ private
|
|
465
478
|
def base_env
|
466
479
|
env = {
|
467
480
|
"RAILS_ENV" => "production",
|
468
|
-
"BUNDLE_DEPLOYMENT" => "1",
|
469
481
|
"BUNDLE_WITHOUT" => options.ci? ? "development" : "development:test"
|
470
482
|
}
|
471
483
|
|
484
|
+
if options.lock?
|
485
|
+
env["BUNDLE_DEPLOYMENT"] = "1"
|
486
|
+
end
|
487
|
+
|
472
488
|
if @@args["base"]
|
473
489
|
env.merge! @@args["base"].to_h { |key, value| [key, "$#{key}"] }
|
474
490
|
end
|
@@ -8,7 +8,7 @@ ARG RUBY_VERSION=<%= RUBY_VERSION %>
|
|
8
8
|
|
9
9
|
<% end -%>
|
10
10
|
<% if options.fullstaq -%>
|
11
|
-
FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%=
|
11
|
+
FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= options.jemalloc ? 'jemalloc-' : '' %>slim<% unless options.precompile == "defer" %> as base<% end %>
|
12
12
|
<% else -%>
|
13
13
|
FROM <%= platform %>ruby:$RUBY_VERSION-slim<% unless options.precompile == "defer" %> as base<% end %>
|
14
14
|
<% end -%>
|
@@ -32,7 +32,7 @@ ENV <%= base_env.join(" \\\n ") %>
|
|
32
32
|
|
33
33
|
# Update gems and bundler
|
34
34
|
RUN gem update --system --no-document && \
|
35
|
-
<% if options.ci? -%>
|
35
|
+
<% if options.ci? and options.lock? -%>
|
36
36
|
gem install -N irb reline && \
|
37
37
|
<% end -%>
|
38
38
|
gem install -N bundler
|
@@ -2,7 +2,7 @@
|
|
2
2
|
COPY <%=sources.join(' ') %> .
|
3
3
|
<% if sources.join.include? 'yarn' -%>
|
4
4
|
RUN <% if options.cache? -%>--mount=type=cache,id=bld-yarn-cache,target=/root/.yarn \
|
5
|
-
YARN_CACHE_FOLDER=/root/.yarn <% end -%>yarn install --frozen-lockfile
|
5
|
+
YARN_CACHE_FOLDER=/root/.yarn <% end -%>yarn install<% if options.lock? %> --frozen-lockfile<% end %>
|
6
6
|
<% else -%>
|
7
7
|
<% if options.cache? -%>
|
8
8
|
RUN --mount=type=cache,id=bld-npm-cache,target=/root/.npm \
|
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.2.
|
4
|
+
version: 1.2.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-02-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|