dockerfile-rails 0.4.2 → 0.4.4

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: 0d84e3358f7afd8b5729d49e6b427e03f92eb6fe5da6a258689e933c09d721a2
4
- data.tar.gz: 897d2a5f53c344c7162953e757b751ff646192ecd880f61cfb1754da5dfbb76d
3
+ metadata.gz: b68e838d9adbcc0404f7f38780918b72d21677922ac627c87bc6d949388e8940
4
+ data.tar.gz: 98a5cf029b0bd032491c47397ddd3439504629a013ecf371e936817b4ada72ec
5
5
  SHA512:
6
- metadata.gz: dd9b469a7c2c562c4cf137670c0d2fa177449c00ccb109e9aca65e0c48cb07d35b0a614c64daaaae699596eb2e191c7da4fcde1fc3da0566c3deed56e1b82494
7
- data.tar.gz: 4ec4f71ecc02555da309027504872e137ccffa936b42ef42c935f2d0349b49cbccdfc39924f284653c952096bc3ea8014d9218eed92e7e71cfac15555e860705
6
+ metadata.gz: 1cc411c1fd37d189592dcacdbad37c572619afb46906d72377dfacc24ef2cf28628d62b898d482cc2845fe1e743304e1abbab44c504da6ccfe6c47b31a7ff16a
7
+ data.tar.gz: f8e4812222ced1477b7707e668bee69834858a66c2dc931822fc822891dc6fdef0608144a9cfd0757e95d7fedffbed6175365337e693bbbae8198ea6e78b4d11
data/README.md CHANGED
@@ -17,6 +17,7 @@ General options:
17
17
 
18
18
  * `--force` - overwrite existing files
19
19
  * `--ci` - include test gems in deployed image
20
+ * `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details.
20
21
  * `--cache` - use build caching to speed up builds
21
22
  * `--parallel` - use multi-stage builds to install gems and node modules in parallel
22
23
  * `--compose` - generate a `docker-compose.yml` file
@@ -36,8 +37,8 @@ Optimizations:
36
37
 
37
38
  * `--fullstaq` - use [fullstaq](https://fullstaqruby.org/) [images](https://github.com/evilmartians/fullstaq-ruby-docker) on [quay.io](https://quay.io/repository/evl.ms/fullstaq-ruby?tab=tags&tag=latest)
38
39
  * `--jemalloc` - use [jemalloc](https://jemalloc.net/) memory allocator
39
- * `--yjit` - enable [YJIT](https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md) optimizing compiler.
40
- * `--swap=n` - allocate swap space. See [falloc options](https://man7.org/linux/man-pages/man1/fallocate.1.html#OPTIONS) for suffixes.
40
+ * `--yjit` - enable [YJIT](https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md) optimizing compiler
41
+ * `--swap=n` - allocate swap space. See [falloc options](https://man7.org/linux/man-pages/man1/fallocate.1.html#OPTIONS) for suffixes
41
42
 
42
43
  Links:
43
44
 
@@ -26,9 +26,13 @@ module DockerfileRails
26
26
  end
27
27
 
28
28
  if File.exist? 'Gemfile'
29
- gemfile_definition = Bundler::Definition.build('Gemfile', nil, [])
30
- @gemfile += gemfile_definition.dependencies.map(&:name)
31
- @git = !gemfile_definition.spec_git_paths.empty?
29
+ begin
30
+ gemfile_definition = Bundler::Definition.build('Gemfile', nil, [])
31
+ @gemfile += gemfile_definition.dependencies.map(&:name)
32
+ @git = !gemfile_definition.spec_git_paths.empty?
33
+ rescue => error
34
+ STDERR.puts error.message
35
+ end
32
36
  end
33
37
 
34
38
  @sidekiq = @gemfile.include? 'sidekiq'
@@ -67,4 +71,4 @@ module DockerfileRails
67
71
  @redis = @redis_cable || @redis_cache || @sidekiq
68
72
  end
69
73
  end
70
- end
74
+ end
@@ -30,6 +30,9 @@ class DockerfileGenerator < Rails::Generators::Base
30
30
  class_option :mysql, type: :boolean, default: false,
31
31
  desc: 'include mysql libraries'
32
32
 
33
+ class_option :platform, type: :string, default: nil,
34
+ desc: 'image platform (example: linux/arm64)'
35
+
33
36
  class_option :jemalloc, type: :boolean, default: false,
34
37
  desc: 'use jemalloc alternative malloc implementation'
35
38
 
@@ -81,6 +84,14 @@ private
81
84
  ERB.new(template, trim_mode: '-').result(scope.get_binding).strip
82
85
  end
83
86
 
87
+ def platform
88
+ if options.platform
89
+ "--platform #{options.platform} "
90
+ else
91
+ ""
92
+ end
93
+ end
94
+
84
95
  def using_node?
85
96
  return @using_node if @using_node != nil
86
97
  @using_node = File.exist? 'package.json'
@@ -8,9 +8,9 @@ ARG RUBY_VERSION=<%= RUBY_VERSION %>
8
8
 
9
9
  <% end -%>
10
10
  <% if options.fullstaq -%>
11
- FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= @options.jemalloc ? 'jemalloc-' : '' %>slim as base
11
+ FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= @options.jemalloc ? 'jemalloc-' : '' %>slim as base
12
12
  <% else -%>
13
- FROM ruby:$RUBY_VERSION-slim as base
13
+ FROM <%= platform %>ruby:$RUBY_VERSION-slim as base
14
14
  <% end -%>
15
15
 
16
16
  # Rails app lives here
@@ -124,7 +124,11 @@ COPY --from=client /rails/<%= api_client_dir %>/build /rails/public
124
124
  ENV RAILS_LOG_TO_STDOUT="1" \
125
125
  RAILS_SERVE_STATIC_FILES="true"<% if options.yjit %> \
126
126
  RUBY_YJIT_ENABLE="1"<% end %><% if options.jemalloc and not options.fullstaq %> \
127
+ <% if (options.platform || Gem::Platform::local.cpu).include? 'arm' -%>
128
+ LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libjemalloc.so.2" \
129
+ <% else -%>
127
130
  LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" \
131
+ <% end -%>
128
132
  MALLOC_CONF="dirty_decay_ms:1000,narenas:2,background_thread:true"<% end %>
129
133
 
130
134
  # Entrypoint prepares the database.
@@ -1,6 +1,6 @@
1
1
  ARG NODE_VERSION=<%= node_version %>
2
2
 
3
- FROM node:$NODE_VERSION-slim as client
3
+ FROM <%= platform %>node:$NODE_VERSION-slim as client
4
4
 
5
5
  WORKDIR /rails/<%= api_client_dir %>
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerfile-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby