dockerfile-rails 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53cc2b6e03a559610e57f74e509e60917c265b4b2b14838cfdf4649195a1eb74
|
4
|
+
data.tar.gz: c2f19f82cf95229926e2d8a409cc46df398d2a05988c6a691dfa51ea81b3a7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 781b58388ee23ceee2b2b0419379659548fb777bc3476b03c1c985e01a1813fddc8bd9aad1876d2d15546e48a36a53a1721bce20ba7a3b85f2dc7c6706bac07d
|
7
|
+
data.tar.gz: 1ded24e677e58592b3e94f5e60afed20021de791949c82288365b9dabd11be57b8fd6e601a77a4368ef6273f027d6330b7d42826d906402c8514c34197a7c96c
|
data/README.md
CHANGED
@@ -14,17 +14,27 @@ bundle add dockerfile-rails --optimistic --group development
|
|
14
14
|
bin/rails generate dockerfile
|
15
15
|
```
|
16
16
|
|
17
|
-
General
|
17
|
+
General option:
|
18
18
|
|
19
19
|
* `--force` - overwrite existing files
|
20
|
+
|
21
|
+
Runtime Optimizations:
|
22
|
+
|
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
|
+
* `--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
|
+
* `--swap=n` - allocate swap space. See [falloc options](https://man7.org/linux/man-pages/man1/fallocate.1.html#OPTIONS) for suffixes
|
27
|
+
|
28
|
+
Features:
|
29
|
+
|
20
30
|
* `--ci` - include test gems in deployed image
|
21
|
-
* `--
|
22
|
-
* `--
|
23
|
-
|
31
|
+
* `--compose` - generate a `docker-compose.yml` file
|
32
|
+
* `--nginx` - serve static files via [nginx](https://www.nginx.com/)
|
33
|
+
|
34
|
+
Build:
|
35
|
+
|
24
36
|
* `--cache` - use build caching to speed up builds
|
25
37
|
* `--parallel` - use multi-stage builds to install gems and node modules in parallel
|
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
|
28
38
|
|
29
39
|
Dependencies:
|
30
40
|
|
@@ -37,12 +47,12 @@ additional support may be needed:
|
|
37
47
|
* `--redis` - add redis libraries
|
38
48
|
* `--sqlite3` - add sqlite3 libraries
|
39
49
|
|
40
|
-
|
50
|
+
Configuration:
|
41
51
|
|
42
|
-
* `--
|
43
|
-
* `--
|
44
|
-
* `--
|
45
|
-
* `--
|
52
|
+
* `--bin-cd` - adjust binstubs to set current working directory
|
53
|
+
* `--no-prepare` - omit `db:prepare`. Useful for cloud platforms with [release](https://devcenter.heroku.com/articles/release-phase) phases
|
54
|
+
* `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details
|
55
|
+
* `--label=name:value` - specify docker label. Can be used multiple times. See [LABEL](https://docs.docker.com/engine/reference/builder/#label) for detail
|
46
56
|
|
47
57
|
Options are saved between runs into `config/dockerfile.yml`. To invert a boolean options, add or remove a `no-` prefix from the option name.
|
48
58
|
|
@@ -20,6 +20,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
20
20
|
'swap' => nil,
|
21
21
|
'yjit' => false,
|
22
22
|
'label' => {},
|
23
|
+
'nginx' => false,
|
23
24
|
)
|
24
25
|
|
25
26
|
@@labels = {}
|
@@ -85,6 +86,9 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
85
86
|
class_option :label, type: :hash, default: {},
|
86
87
|
desc: 'Add Docker label(s)'
|
87
88
|
|
89
|
+
class_option :nginx, type: :boolean, default: OPTION_DEFAULTS.nginx,
|
90
|
+
desc: 'Serve static files with nginx'
|
91
|
+
|
88
92
|
def generate_app
|
89
93
|
source_paths.push File.expand_path('./templates', __dir__)
|
90
94
|
|
@@ -297,6 +301,9 @@ private
|
|
297
301
|
# Puppeteer
|
298
302
|
packages << 'google-chrome-stable' if using_puppeteer?
|
299
303
|
|
304
|
+
# nginx
|
305
|
+
packages << 'nginx' if options.nginx?
|
306
|
+
|
300
307
|
packages.sort
|
301
308
|
end
|
302
309
|
|
@@ -321,16 +328,18 @@ private
|
|
321
328
|
def deploy_env
|
322
329
|
env = []
|
323
330
|
|
331
|
+
env << 'PORT="3001"' if options.nginx?
|
332
|
+
|
324
333
|
if Rails::VERSION::MAJOR<7 || Rails::VERSION::STRING.start_with?('7.0')
|
325
334
|
env << 'RAILS_LOG_TO_STDOUT="1"'
|
326
|
-
env << 'RAILS_SERVE_STATIC_FILES="true"'
|
335
|
+
env << 'RAILS_SERVE_STATIC_FILES="true"' unless options.nginx?
|
327
336
|
end
|
328
337
|
|
329
|
-
if options.yjit
|
338
|
+
if options.yjit?
|
330
339
|
env << 'RUBY_YJIT_ENABLE="1"'
|
331
340
|
end
|
332
341
|
|
333
|
-
if options.jemalloc and not options.fullstaq
|
342
|
+
if options.jemalloc? and not options.fullstaq?
|
334
343
|
if (options.platform || Gem::Platform::local.cpu).include? 'arm'
|
335
344
|
env << 'LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libjemalloc.so.2"'
|
336
345
|
else
|
@@ -473,4 +482,17 @@ private
|
|
473
482
|
'db:migrate'
|
474
483
|
end
|
475
484
|
end
|
485
|
+
|
486
|
+
def procfile
|
487
|
+
if options.nginx?
|
488
|
+
{
|
489
|
+
nginx: 'nginx -g "daemon off;"',
|
490
|
+
rails: './bin/rails server -p 3001'
|
491
|
+
}
|
492
|
+
else
|
493
|
+
{
|
494
|
+
rails: './bin/rails server'
|
495
|
+
}
|
496
|
+
end
|
497
|
+
end
|
476
498
|
end
|
@@ -123,6 +123,13 @@ FROM base
|
|
123
123
|
<%= render partial: 'apt_install', locals: {packages: deploy_packages, clean: true, repos: deploy_repos} %>
|
124
124
|
<% end -%>
|
125
125
|
|
126
|
+
<% if options.nginx? -%>
|
127
|
+
<%= render partial: 'nginx' %>
|
128
|
+
|
129
|
+
<% elsif procfile.size > 1 -%>
|
130
|
+
RUN gem install foreman
|
131
|
+
|
132
|
+
<% end -%>
|
126
133
|
# Copy built application from previous stage
|
127
134
|
<% if options.ci? -%>
|
128
135
|
COPY --from=build /usr/local/bundle /usr/local/bundle
|
@@ -146,6 +153,19 @@ ENV <%= deploy_env.join(" \\\n ") %>
|
|
146
153
|
<% end -%>
|
147
154
|
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
148
155
|
|
156
|
+
<% if procfile.size > 1 -%>
|
157
|
+
# Build a Procfile for production use
|
158
|
+
COPY <<-"EOF" /rails/Procfile.prod
|
159
|
+
<% procfile.each do |name, command| -%>
|
160
|
+
<%= name %>: <%= command %>
|
161
|
+
<% end -%>
|
162
|
+
EOF
|
163
|
+
|
164
|
+
# Start the server by default, this can be overwritten at runtime
|
165
|
+
EXPOSE 3000
|
166
|
+
CMD ["foreman", "start", "--procfile=Procfile.prod"]
|
167
|
+
<% else -%>
|
149
168
|
# Start the server by default, this can be overwritten at runtime
|
150
169
|
EXPOSE 3000
|
151
170
|
CMD ["./bin/rails", "server"]
|
171
|
+
<% end -%>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# configure nginx
|
2
|
-
RUN
|
3
|
-
sed -i 's/
|
4
|
-
sed -i
|
2
|
+
RUN gem install foreman && \
|
3
|
+
sed -i 's/access_log\s.*;/access_log \/dev\/stdout;/' /etc/nginx/nginx.conf && \
|
4
|
+
sed -i 's/error_log\s.*;/error_log \/dev\/stderr info;/' /etc/nginx/nginx.conf
|
5
5
|
|
6
6
|
COPY <<-"EOF" /etc/nginx/sites-available/default
|
7
7
|
server {
|
@@ -11,8 +11,13 @@ echo 1 > /proc/sys/vm/overcommit_memory
|
|
11
11
|
|
12
12
|
<% end -%>
|
13
13
|
<% if options.prepare -%>
|
14
|
+
<% if procfile.size > 1 -%>
|
15
|
+
# If running the production procfile then create or migrate existing database
|
16
|
+
if [ "${*}" == "foreman start --procfile=Procfile.prod" ]; then
|
17
|
+
<% else -%>
|
14
18
|
# If running the rails server then create or migrate existing database
|
15
19
|
if [ "${*}" == "./bin/rails server" ]; then
|
20
|
+
<% end -%>
|
16
21
|
./bin/rails <%= dbprep_command %>
|
17
22
|
fi
|
18
23
|
|
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.10
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|