dockerfile-rails 1.0.13 → 1.0.15
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: 643e89aa7b925c6eafb7a39646fbc7a3598ed3a0ac1733c94b8baed912e814c9
|
4
|
+
data.tar.gz: 2235072e0a79ecb5011d720287e18641d5e44263498db0b33e2f3dc0e223911f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 244a1ccd3abc9fd668d76726728c600a8edd1ecd30a735f116973da58d021bf2f980780f7b0694f87b217a601259d7c5d96f7b284960f577bd82a3ac5c76b988
|
7
|
+
data.tar.gz: 5f6f2dc75d9014aa7b3d79314a6cb09af2f284ca847300fc57aa056518c95b18a4b421c00c6c490a707fbfba0b60717ba71d2aaa26e216e12cc9d30efadc94b2
|
data/README.md
CHANGED
@@ -22,8 +22,13 @@ Runtime Optimizations:
|
|
22
22
|
|
23
23
|
* `--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)
|
24
24
|
* `--jemalloc` - use [jemalloc](https://jemalloc.net/) memory allocator
|
25
|
-
* `--yjit` - enable [YJIT](https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md) optimizing compiler
|
26
25
|
* `--swap=n` - allocate swap space. See [falloc options](https://man7.org/linux/man-pages/man1/fallocate.1.html#OPTIONS) for suffixes
|
26
|
+
* `--yjit` - enable [YJIT](https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md) optimizing compiler
|
27
|
+
|
28
|
+
Build optimizations:
|
29
|
+
|
30
|
+
* `--cache` - use build caching to speed up builds
|
31
|
+
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
|
27
32
|
|
28
33
|
Features:
|
29
34
|
|
@@ -31,11 +36,6 @@ Features:
|
|
31
36
|
* `--compose` - generate a `docker-compose.yml` file
|
32
37
|
* `--nginx` - serve static files via [nginx](https://www.nginx.com/)
|
33
38
|
|
34
|
-
Build:
|
35
|
-
|
36
|
-
* `--cache` - use build caching to speed up builds
|
37
|
-
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
|
38
|
-
|
39
39
|
Dependencies:
|
40
40
|
|
41
41
|
Generally the dockerfile generator will be able to determine what dependencies you
|
@@ -50,9 +50,10 @@ additional support may be needed:
|
|
50
50
|
Configuration:
|
51
51
|
|
52
52
|
* `--bin-cd` - adjust binstubs to set current working directory
|
53
|
+
* `--label=name:value` - specify docker label. Can be used multiple times. See [LABEL](https://docs.docker.com/engine/reference/builder/#label) for detail
|
53
54
|
* `--no-prepare` - omit `db:prepare`. Useful for cloud platforms with [release](https://devcenter.heroku.com/articles/release-phase) phases
|
54
55
|
* `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details
|
55
|
-
* `--
|
56
|
+
* `--precompile=defer` - may be needed when your configuration requires access to secrets that are not available at build time. Results in larger images and slower deployments.
|
56
57
|
|
57
58
|
Options are saved between runs into `config/dockerfile.yml`. To invert a boolean options, add or remove a `no-` prefix from the option name.
|
58
59
|
|
@@ -15,6 +15,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
15
15
|
'parallel' => false,
|
16
16
|
'platform' => nil,
|
17
17
|
'postgresql' => false,
|
18
|
+
'precompile' => nil,
|
18
19
|
'prepare' => true,
|
19
20
|
'redis' => false,
|
20
21
|
'swap' => nil,
|
@@ -41,6 +42,9 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
41
42
|
class_option :ci, type: :boolean, default: OPTION_DEFAULTS.ci,
|
42
43
|
desc: 'include test gems in bundle'
|
43
44
|
|
45
|
+
class_option :precompile, type: :string, default: OPTION_DEFAULTS.precompile,
|
46
|
+
desc: 'if set to "defer", assets:precompile will be done at deploy time'
|
47
|
+
|
44
48
|
class_option 'bin-cd', type: :boolean, default: OPTION_DEFAULTS['bin-cd'],
|
45
49
|
desc: 'modify binstubs to set working directory'
|
46
50
|
|
@@ -118,6 +122,17 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
118
122
|
template 'docker-compose.yml.erb', 'docker-compose.yml' if options.compose
|
119
123
|
|
120
124
|
template 'dockerfile.yml.erb', 'config/dockerfile.yml', force: true
|
125
|
+
|
126
|
+
if @gemfile.include?('vite_ruby')
|
127
|
+
package = JSON.load_file('package.json')
|
128
|
+
unless package.dig('scripts', 'build')
|
129
|
+
package['scripts'] ||= {}
|
130
|
+
package['scripts']['build'] = 'vite build --outDir public'
|
131
|
+
|
132
|
+
say_status :update, 'package.json'
|
133
|
+
IO.write('package.json', JSON.pretty_generate(package))
|
134
|
+
end
|
135
|
+
end
|
121
136
|
end
|
122
137
|
|
123
138
|
private
|
@@ -261,10 +276,12 @@ private
|
|
261
276
|
# is based on debian release included with the Ruby images on
|
262
277
|
# Dockerhub.
|
263
278
|
case RUBY_VERSION
|
264
|
-
when /^2
|
279
|
+
when /^2\.7/
|
265
280
|
bullseye = RUBY_VERSION >= "2.7.4"
|
266
|
-
when /^3
|
281
|
+
when /^3\.0/
|
267
282
|
bullseye = RUBY_VERSION >= "3.0.2"
|
283
|
+
when /^2\./
|
284
|
+
bullseye = false
|
268
285
|
else
|
269
286
|
bullseye = true
|
270
287
|
end
|
@@ -495,4 +512,15 @@ private
|
|
495
512
|
}
|
496
513
|
end
|
497
514
|
end
|
515
|
+
|
516
|
+
def more_docker_ignores
|
517
|
+
more = ''
|
518
|
+
|
519
|
+
if @gemfile.include?('vite_ruby')
|
520
|
+
lines = IO.read('.gitignore')[/^# Vite.*?\n\n/m].to_s.chomp.lines -
|
521
|
+
["node_modules\n"]
|
522
|
+
|
523
|
+
more += "\n" + lines.join
|
524
|
+
end
|
525
|
+
end
|
498
526
|
end
|
@@ -8,9 +8,9 @@ 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}-<%= @options.jemalloc ? 'jemalloc-' : '' %>slim as base
|
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
|
-
FROM <%= platform %>ruby:$RUBY_VERSION-slim as base
|
13
|
+
FROM <%= platform %>ruby:$RUBY_VERSION-slim<% unless options.precompile == "defer" %> as base<% end %>
|
14
14
|
<% end -%>
|
15
15
|
|
16
16
|
<% unless options.label.empty? -%>
|
@@ -44,10 +44,12 @@ RUN gem update --system --no-document && \
|
|
44
44
|
<%= render partial: 'install_node', locals: {yarn_version: nil} %>
|
45
45
|
|
46
46
|
<% end -%>
|
47
|
+
<% unless options.precompile == "defer" -%>
|
47
48
|
|
48
49
|
# Throw-away build stage<%= parallel? ? 's' : '' %> to reduce size of final image
|
49
50
|
FROM base as <%= parallel? ? 'pre' : '' %>build
|
50
51
|
|
52
|
+
<% end -%>
|
51
53
|
# Install packages needed to build gems<%= using_node? ? " and node modules" : "" %>
|
52
54
|
<%= render partial: 'apt_install', locals: {packages: build_packages, clean: false, repos: ''} %>
|
53
55
|
|
@@ -112,6 +114,7 @@ RUN bundle exec bootsnap precompile app/ lib/
|
|
112
114
|
<%= "RUN " + binfile_fixups.join(" && \\\n ") %>
|
113
115
|
|
114
116
|
<% end -%>
|
117
|
+
<% unless options.precompile == "defer" -%>
|
115
118
|
<% if Dir.exist?('app/assets') and !api_only? -%>
|
116
119
|
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
117
120
|
RUN SECRET_KEY_BASE<%= Rails::VERSION::MAJOR<7 || Rails::VERSION::STRING.start_with?('7.0') ? '=DUMMY' : '_DUMMY=1' %> ./bin/rails assets:precompile
|
@@ -120,8 +123,9 @@ RUN SECRET_KEY_BASE<%= Rails::VERSION::MAJOR<7 || Rails::VERSION::STRING.start_w
|
|
120
123
|
|
121
124
|
# Final stage for app image
|
122
125
|
FROM base
|
123
|
-
<% unless deploy_packages.empty? -%>
|
124
126
|
|
127
|
+
<% end -%>
|
128
|
+
<% unless deploy_packages.empty? -%>
|
125
129
|
# Install packages needed for deployment
|
126
130
|
<%= render partial: 'apt_install', locals: {packages: deploy_packages, clean: true, repos: deploy_repos} %>
|
127
131
|
<% end -%>
|
@@ -133,6 +137,7 @@ FROM base
|
|
133
137
|
RUN gem install foreman
|
134
138
|
|
135
139
|
<% end -%>
|
140
|
+
<% unless options.precompile == "defer" -%>
|
136
141
|
# Copy built application from previous stage
|
137
142
|
COPY --from=build /rails /rails
|
138
143
|
<% if api_client_dir -%>
|
@@ -141,6 +146,7 @@ COPY --from=build /rails /rails
|
|
141
146
|
COPY --from=client /rails/<%= api_client_dir %>/build /rails/public
|
142
147
|
<% end -%>
|
143
148
|
|
149
|
+
<% end -%>
|
144
150
|
<% unless deploy_env.empty? -%>
|
145
151
|
# Deployment options
|
146
152
|
ENV <%= deploy_env.join(" \\\n ") %>
|
@@ -17,6 +17,9 @@ if [ "${*}" == "foreman start --procfile=Procfile.prod" ]; then
|
|
17
17
|
<% else -%>
|
18
18
|
# If running the rails server then create or migrate existing database
|
19
19
|
if [ "${*}" == "./bin/rails server" ]; then
|
20
|
+
<% end -%>
|
21
|
+
<% if options.precompile == "defer" -%>
|
22
|
+
./bin/rails assets:precompile
|
20
23
|
<% end -%>
|
21
24
|
./bin/rails <%= dbprep_command %>
|
22
25
|
fi
|
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.15
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|