dockerfile-rails 1.0.1 → 1.0.3
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:
|
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
@@ -10,7 +10,7 @@ Provides a Rails generator to produce Dockerfiles and related files. This is be
|
|
10
10
|
## Usage
|
11
11
|
|
12
12
|
```
|
13
|
-
bundle add dockerfile-rails --
|
13
|
+
bundle add dockerfile-rails --optimistic --group development
|
14
14
|
bin/rails generate dockerfile
|
15
15
|
```
|
16
16
|
|
@@ -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
|
|
@@ -40,9 +40,7 @@ module DockerfileRails
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
@sidekiq = @gemfile.include? 'sidekiq'
|
44
43
|
@anycable = @gemfile.include? 'anycable-rails'
|
45
|
-
@rmagick = @gemfile.include? 'rmagick'
|
46
44
|
@vips = @gemfile.include? 'ruby-vips'
|
47
45
|
@bootstrap = @gemfile.include? 'bootstrap'
|
48
46
|
@puppeteer = @gemfile.include? 'puppeteer'
|
@@ -73,7 +71,7 @@ module DockerfileRails
|
|
73
71
|
@redis_cache = true
|
74
72
|
end
|
75
73
|
|
76
|
-
@redis = @redis_cable || @redis_cache
|
74
|
+
@redis = @redis_cable || @redis_cache
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
@@ -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|
|
@@ -142,7 +154,7 @@ private
|
|
142
154
|
end
|
143
155
|
|
144
156
|
def using_redis?
|
145
|
-
options.redis? or @redis
|
157
|
+
options.redis? or @redis or @gemfile.include?('sidekiq')
|
146
158
|
end
|
147
159
|
|
148
160
|
def using_execjs?
|
@@ -150,7 +162,11 @@ private
|
|
150
162
|
end
|
151
163
|
|
152
164
|
def using_puppeteer?
|
153
|
-
@gemfile.include?('grover')
|
165
|
+
@gemfile.include?('grover') or @gemfile.include?('puppeteer-ruby')
|
166
|
+
end
|
167
|
+
|
168
|
+
def using_sidekiq?
|
169
|
+
@gemfile.include?('sidekiq')
|
154
170
|
end
|
155
171
|
|
156
172
|
def parallel?
|
@@ -176,6 +192,27 @@ private
|
|
176
192
|
end
|
177
193
|
end
|
178
194
|
|
195
|
+
def base_packages
|
196
|
+
packages = []
|
197
|
+
|
198
|
+
if using_execjs?
|
199
|
+
packages += %w(curl unzip)
|
200
|
+
end
|
201
|
+
|
202
|
+
if using_puppeteer?
|
203
|
+
packages += %w(curl gnupg)
|
204
|
+
end
|
205
|
+
|
206
|
+
packages.sort.uniq
|
207
|
+
end
|
208
|
+
|
209
|
+
def base_requirements
|
210
|
+
requirements = []
|
211
|
+
requirements << 'nodejs' if using_execjs?
|
212
|
+
requirements << 'chrome' if using_puppeteer?
|
213
|
+
requirements.join(' and ')
|
214
|
+
end
|
215
|
+
|
179
216
|
def build_packages
|
180
217
|
# start with the essentials
|
181
218
|
packages = %w(build-essential)
|
@@ -188,7 +225,7 @@ private
|
|
188
225
|
# add git if needed to install gems
|
189
226
|
packages << 'git' if @git
|
190
227
|
|
191
|
-
# add redis
|
228
|
+
# add redis if Action Cable, caching, or sidekiq are used
|
192
229
|
packages << "redis" if options.redis? or using_redis?
|
193
230
|
|
194
231
|
# ActiveStorage preview support
|
@@ -200,7 +237,7 @@ private
|
|
200
237
|
# node support, including support for building native modules
|
201
238
|
if using_node?
|
202
239
|
packages += %w(node-gyp pkg-config)
|
203
|
-
packages += %w(curl unzip) unless using_execjs?
|
240
|
+
packages += %w(curl unzip) unless using_execjs? or using_puppeteer?
|
204
241
|
|
205
242
|
# module build process depends on Python, and debian changed
|
206
243
|
# how python is installed with the bullseye release. Below
|
@@ -240,7 +277,9 @@ private
|
|
240
277
|
packages << "libvips" if @gemfile.include? 'ruby-vips'
|
241
278
|
|
242
279
|
# Rmagick gem
|
243
|
-
|
280
|
+
if @gemfile.include?('rmagick') or @gemfile.include?('mini_magick')
|
281
|
+
packages << 'imagemagick'
|
282
|
+
end
|
244
283
|
|
245
284
|
# Puppeteer
|
246
285
|
packages << 'google-chrome-stable' if using_puppeteer?
|
@@ -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
|
|
@@ -26,15 +32,12 @@ ARG BUNDLER_VERSION=<%= Bundler::VERSION %>
|
|
26
32
|
RUN gem update --system --no-document && \
|
27
33
|
gem install -N bundler -v ${BUNDLER_VERSION}
|
28
34
|
|
29
|
-
<%
|
30
|
-
|
31
|
-
|
32
|
-
<%= render partial: 'apt_install', locals: {packages: %w(curl gnupg unzip), clean: true, repos: ''} %>
|
33
|
-
<% else -%>
|
34
|
-
# Install packages needed to install nodejs
|
35
|
-
<%= render partial: 'apt_install', locals: {packages: %w(curl unzip), clean: true, repos: ''} %>
|
36
|
-
<% end -%>
|
35
|
+
<% unless base_requirements.empty? -%>
|
36
|
+
# Install packages needed to install <%= base_requirements %>
|
37
|
+
<%= render partial: 'apt_install', locals: {packages: base_packages, clean: true, repos: ''} %>
|
37
38
|
|
39
|
+
<% end -%>
|
40
|
+
<% if using_execjs? -%>
|
38
41
|
<%= render partial: 'install_node', locals: {yarn_version: nil} %>
|
39
42
|
|
40
43
|
<% end -%>
|
@@ -68,4 +68,27 @@ services:
|
|
68
68
|
|
69
69
|
redis-db:
|
70
70
|
image: redis
|
71
|
+
<% end -%>
|
72
|
+
<% if using_sidekiq? and deploy_database != 'sqlite3' -%>
|
73
|
+
|
74
|
+
sidekiq:
|
75
|
+
build: .
|
76
|
+
environment:
|
77
|
+
- RAILS_MASTER_KEY=$RAILS_MASTER_KEY
|
78
|
+
- REDIS_URL=redis://redis-db:6379
|
79
|
+
<% if deploy_database == 'postgresql' -%>
|
80
|
+
- DATABASE_URL=postgres://root:password@postgres-db/
|
81
|
+
<% elsif deploy_database == 'mysql' -%>
|
82
|
+
- DATABASE_URL=mysql2://root:password@mysql-db/
|
83
|
+
<% end -%>
|
84
|
+
depends_on:
|
85
|
+
redis-db:
|
86
|
+
condition: service_started
|
87
|
+
<% if deploy_database == 'postgresql' -%>
|
88
|
+
postgres-db:
|
89
|
+
condition: service_healthy
|
90
|
+
<% elsif deploy_database == 'mysql' -%>
|
91
|
+
mysql-db:
|
92
|
+
condition: service_healthy
|
93
|
+
<% end -%>
|
71
94
|
<% 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.0.
|
4
|
+
version: 1.0.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-01
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|