dockerfile-rails 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/generators/dockerfile_generator.rb +12 -0
- data/lib/generators/templates/Dockerfile.erb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca1f4e5fe001307e03c7a37ad194cc643b0130d709a3974c453dc036857eb4a8
|
4
|
+
data.tar.gz: 81508d5aa170bfc00062ce1fb52ca54237def089702937b13ce7ae56e95f99a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f75d96502988be41600c72ee59a6bfd32d583fc8e0d1c9ea59c3a4c478bcefb484510b4db03fd8c28730d356944f62678244ceb5ac8d4bd4769de166760700
|
7
|
+
data.tar.gz: 9f75d764d9ad5badedfd6c935796db84e7988441a2c87fc12eab78c1a2cbae67eaeffed1f2f14b2a28c89df0f6cb13222c9653c983ef85540cc2acb8986568f0
|
data/README.md
CHANGED
@@ -19,11 +19,12 @@ General options:
|
|
19
19
|
* `--force` - overwrite existing files
|
20
20
|
* `--ci` - include test gems in deployed image
|
21
21
|
* `--bin-cd` - adjust binstubs to set current working directory
|
22
|
-
* `--no-prepare` - omit `db:prepare`. Useful for cloud platforms with [release](https://devcenter.heroku.com/articles/release-phase) phases
|
23
|
-
* `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details
|
22
|
+
* `--no-prepare` - omit `db:prepare`. Useful for cloud platforms with [release](https://devcenter.heroku.com/articles/release-phase) phases
|
23
|
+
* `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details
|
24
24
|
* `--cache` - use build caching to speed up builds
|
25
25
|
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
|
26
26
|
* `--compose` - generate a `docker-compose.yml` file
|
27
|
+
* `--label=name:value` - specify docker label. Can be used multiple times. See [LABEL](https://docs.docker.com/engine/reference/builder/#label) for details
|
27
28
|
|
28
29
|
Dependencies:
|
29
30
|
|
@@ -19,15 +19,21 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
19
19
|
'redis' => false,
|
20
20
|
'swap' => nil,
|
21
21
|
'yjit' => false,
|
22
|
+
'label' => {},
|
22
23
|
)
|
23
24
|
|
25
|
+
@@labels = {}
|
26
|
+
|
24
27
|
# load defaults from config file
|
25
28
|
if File.exist? 'config/dockerfile.yml'
|
26
29
|
options = YAML.safe_load_file('config/dockerfile.yml', symbolize_names: true)[:options]
|
30
|
+
|
27
31
|
if options
|
28
32
|
OPTION_DEFAULTS.to_h.each do |option, value|
|
29
33
|
OPTION_DEFAULTS[option] = options[option] if options.include? option
|
30
34
|
end
|
35
|
+
|
36
|
+
@@labels = options[:label].stringify_keys if options.include? :label
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
@@ -76,9 +82,15 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
76
82
|
class_option :yjit, type: :boolean, default: OPTION_DEFAULTS.yjit,
|
77
83
|
desc: 'enable YJIT optimizing compiler'
|
78
84
|
|
85
|
+
class_option :label, type: :hash, default: {},
|
86
|
+
desc: 'Add Docker label(s)'
|
87
|
+
|
79
88
|
def generate_app
|
80
89
|
source_paths.push File.expand_path('./templates', __dir__)
|
81
90
|
|
91
|
+
# merge options
|
92
|
+
options.label.replace(@@labels.merge(options.label).select {|key, value| value != ''})
|
93
|
+
|
82
94
|
# gather up options for config file
|
83
95
|
@dockerfile_config = OPTION_DEFAULTS.dup.to_h.stringify_keys
|
84
96
|
options.to_h.each do |option, value|
|
@@ -13,6 +13,12 @@ FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= @options.je
|
|
13
13
|
FROM <%= platform %>ruby:$RUBY_VERSION-slim as base
|
14
14
|
<% end -%>
|
15
15
|
|
16
|
+
<% unless options.label.empty? -%>
|
17
|
+
<% options.label.each do |key, value| -%>
|
18
|
+
LABEL <%= key =~ /^\w[.\w]*$/ ? key : key.inspect %>=<%= value.inspect %>
|
19
|
+
<% end -%>
|
20
|
+
|
21
|
+
<% end -%>
|
16
22
|
# Rails app lives here
|
17
23
|
WORKDIR /rails
|
18
24
|
|