dockerfile-rails 1.0.13 → 1.0.14
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: 850bc5224e5a60f46df7ddf4c7c31374d891d27fc2145a15cb1eb021f798f63f
|
4
|
+
data.tar.gz: a4254547f34fbd026215ec07c1f4c81a1eef9a15780cbc5b664cb05df5e70ef3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e21fea124f3293d384c0fcaae6f1001985a81e5ed229b8b49d321733f61b98c8f46f5cd9586ad35c37198604e90ddbd107ad54e2a09a0d1b96067791c31c48
|
7
|
+
data.tar.gz: 52eed0118d7eb11ffe6833f4e6339d7736174d2035e94eee369d05586e6c0fe44051907481ec065e1e4d88212abc692277838c3ea34865dbbb2e3053e68de505
|
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
|
@@ -495,4 +510,15 @@ private
|
|
495
510
|
}
|
496
511
|
end
|
497
512
|
end
|
513
|
+
|
514
|
+
def more_docker_ignores
|
515
|
+
more = ''
|
516
|
+
|
517
|
+
if @gemfile.include?('vite_ruby')
|
518
|
+
lines = IO.read('.gitignore')[/^# Vite.*?\n\n/m].to_s.chomp.lines -
|
519
|
+
["node_modules\n"]
|
520
|
+
|
521
|
+
more += "\n" + lines.join
|
522
|
+
end
|
523
|
+
end
|
498
524
|
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.14
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|