dockerfile-rails 1.1.1 → 1.2.0
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 +4 -4
- data/DEMO.md +5 -3
- data/README.md +2 -1
- data/lib/generators/dockerfile_generator.rb +27 -11
- data/lib/generators/templates/Dockerfile.erb +5 -6
- data/lib/generators/templates/_install_node.erb +6 -4
- data/lib/generators/templates/_nginx.erb +3 -0
- data/lib/generators/templates/_npm_install.erb +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8dc8b1f01f52091af8e9cb3322db265d96698e80fc203bfc570135efd69cb06
|
4
|
+
data.tar.gz: 6054ee7cb322ed79092c6205cce1969b7ab9ad1d868113024845d90bb52d4448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 938d057a8f5faf7cca766898b5f6406a379bf90c1fc6116c05759e38a7d7439efdad941855a8cdf4029cc9aadd0131d7463a855e702fe8a69b7746250e1bfbd5
|
7
|
+
data.tar.gz: 4be1203c6fa6176c867dae6ef78511aa5e0a3c9943958430a8b77ba04cbb5368371d4ea3e100d4a037946cfd0f94ee7ced7425a1464bfe75450a3c1cc8703dbc
|
data/DEMO.md
CHANGED
@@ -310,10 +310,12 @@ docker buildx build . -t rails-demo
|
|
310
310
|
docker run -p 3000:3000 -e RAILS_MASTER_KEY=$(cat config/master.key) rails-demo
|
311
311
|
```
|
312
312
|
|
313
|
-
# Demo 6 - Grover / puppeteer /
|
313
|
+
# Demo 6 - Grover / puppeteer / Chromium
|
314
314
|
|
315
|
-
|
316
|
-
|
315
|
+
Uses Grover to produce a PDF of a web page. If you specify a `--platform` that
|
316
|
+
contains `amd64`, chrome will be substituted for Chromium. `--platform` is
|
317
|
+
required to access Chrome as Google doesn't supply Chrome binaries for Linux on
|
318
|
+
ARM.
|
317
319
|
|
318
320
|
```bash
|
319
321
|
rails new demo --minimal
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ bin/rails generate dockerfile
|
|
40
40
|
|
41
41
|
* `--ci` - include test gems in deployed image
|
42
42
|
* `--compose` - generate a `docker-compose.yml` file
|
43
|
-
* `--nginx` - serve static files via [nginx](https://www.nginx.com/)
|
43
|
+
* `--nginx` - serve static files via [nginx](https://www.nginx.com/). May require `--root` on some targets to access `/dev/stdout`
|
44
44
|
|
45
45
|
### Add a Database:
|
46
46
|
|
@@ -108,3 +108,4 @@ The following links relate to the current development status with respect to Rai
|
|
108
108
|
* [app/templates/Dockerfile.tt](https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt) - current Rails 7.1 template
|
109
109
|
* Fly.io [Cut over to Rails Dockerfile Generator on Sunday 29 Jan 2023](https://community.fly.io/t/cut-over-to-rails-dockerfile-generator-on-sunday-29-jan-2023/10350)
|
110
110
|
* Fly.io [FAQ](https://fly.io/docs/rails/getting-started/dockerfiles/)
|
111
|
+
* DDH's [target](https://github.com/rails/rails/pull/47372#issuecomment-1438971730)
|
@@ -259,7 +259,7 @@ private
|
|
259
259
|
end
|
260
260
|
|
261
261
|
def run_as_root?
|
262
|
-
options.root?
|
262
|
+
options.root?
|
263
263
|
end
|
264
264
|
|
265
265
|
def using_node?
|
@@ -311,7 +311,7 @@ private
|
|
311
311
|
packages += @@packages["base"] if @@packages["base"]
|
312
312
|
|
313
313
|
if using_execjs?
|
314
|
-
packages += %w(curl
|
314
|
+
packages += %w(curl)
|
315
315
|
end
|
316
316
|
|
317
317
|
if using_puppeteer?
|
@@ -364,7 +364,7 @@ private
|
|
364
364
|
# node support, including support for building native modules
|
365
365
|
if using_node?
|
366
366
|
packages += %w(node-gyp pkg-config)
|
367
|
-
packages += %w(curl
|
367
|
+
packages += %w(curl) unless using_execjs? || using_puppeteer?
|
368
368
|
|
369
369
|
# module build process depends on Python, and debian changed
|
370
370
|
# how python is installed with the bullseye release. Below
|
@@ -412,7 +412,13 @@ private
|
|
412
412
|
end
|
413
413
|
|
414
414
|
# Puppeteer
|
415
|
-
|
415
|
+
if using_puppeteer?
|
416
|
+
if options.platform&.include? "amd"
|
417
|
+
packages << "google-chrome-stable"
|
418
|
+
else
|
419
|
+
packages += %w(chromium chromium-sandbox)
|
420
|
+
end
|
421
|
+
end
|
416
422
|
|
417
423
|
# nginx
|
418
424
|
packages << "nginx" if options.nginx?
|
@@ -423,7 +429,7 @@ private
|
|
423
429
|
def deploy_repos
|
424
430
|
repos = []
|
425
431
|
|
426
|
-
if using_puppeteer?
|
432
|
+
if using_puppeteer? && deploy_packages.include?("google-chrome-stable")
|
427
433
|
repos += [
|
428
434
|
"curl https://dl-ssl.google.com/linux/linux_signing_key.pub |",
|
429
435
|
"gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&",
|
@@ -457,6 +463,14 @@ private
|
|
457
463
|
def build_env
|
458
464
|
env = {}
|
459
465
|
|
466
|
+
if using_execjs?
|
467
|
+
env["PATH"] = "/usr/local/node/bin:$PATH"
|
468
|
+
end
|
469
|
+
|
470
|
+
if using_puppeteer?
|
471
|
+
env["PUPPETEER_SKIP_CHROMIUM_DOWNLOAD"] = "true"
|
472
|
+
end
|
473
|
+
|
460
474
|
if @@args["build"]
|
461
475
|
env.merge! @@args["build"].to_h { |key, value| [key, "$#{key}"] }
|
462
476
|
end
|
@@ -491,12 +505,14 @@ private
|
|
491
505
|
end
|
492
506
|
|
493
507
|
if using_puppeteer?
|
494
|
-
if
|
495
|
-
|
496
|
-
env["PUPPETEER_RUBY_NO_SANDBOX"] = "1" if @gemfile.include? "puppeteer-ruby"
|
497
|
-
end
|
508
|
+
env["GROVER_NO_SANDBOX"] = "true" if @gemfile.include? "grover"
|
509
|
+
env["PUPPETEER_RUBY_NO_SANDBOX"] = "1" if @gemfile.include? "puppeteer-ruby"
|
498
510
|
|
499
|
-
|
511
|
+
if options.platform&.include? "amd"
|
512
|
+
env["PUPPETEER_EXECUTABLE_PATH"] = "/usr/bin/google-chrome"
|
513
|
+
else
|
514
|
+
env["PUPPETEER_EXECUTABLE_PATH"] = "/usr/bin/chromium"
|
515
|
+
end
|
500
516
|
end
|
501
517
|
|
502
518
|
if @@args["deploy"]
|
@@ -675,7 +691,7 @@ private
|
|
675
691
|
def procfile
|
676
692
|
if options.nginx?
|
677
693
|
{
|
678
|
-
nginx: 'nginx -g "daemon off;"',
|
694
|
+
nginx: '/usr/sbin/nginx -g "daemon off;"',
|
679
695
|
rails: "./bin/rails server -p 3001"
|
680
696
|
}
|
681
697
|
else
|
@@ -78,7 +78,7 @@ ARG <%= build_args.map {|key, value| "#{key}=#{value.inspect}"}.join(" \\\n "
|
|
78
78
|
|
79
79
|
<% end -%>
|
80
80
|
<% unless build_env.empty? -%>
|
81
|
-
#
|
81
|
+
# Build options
|
82
82
|
ENV <%= build_env.join(" \\\n ") %>
|
83
83
|
|
84
84
|
<% end -%>
|
@@ -156,15 +156,14 @@ RUN gem install foreman
|
|
156
156
|
|
157
157
|
<% end -%>
|
158
158
|
<% unless run_as_root? -%>
|
159
|
-
#
|
159
|
+
# Run and own the application files as a non-root user for security
|
160
160
|
<% if options.compose? -%>
|
161
161
|
ARG UID=1000 \
|
162
162
|
GID=1000
|
163
163
|
RUN groupadd -f -g $GID rails && \
|
164
|
-
useradd -u $UID -g $GID rails
|
165
|
-
<%
|
166
|
-
|
167
|
-
<% end -%>
|
164
|
+
useradd -u $UID -g $GID rails<% else -%>
|
165
|
+
RUN useradd rails<% end -%><% if options.nginx? %> && \
|
166
|
+
chown rails:rails /var/lib/nginx /var/log/nginx/*<% end %>
|
168
167
|
USER rails:rails
|
169
168
|
|
170
169
|
<% end -%>
|
@@ -12,9 +12,11 @@ ARG NODE_VERSION=<%= node_version %>
|
|
12
12
|
ARG YARN_VERSION=<%= yarn_version %>
|
13
13
|
<% end -%>
|
14
14
|
<% if node_version -%>
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
ENV PATH=/usr/local/node/bin:$PATH
|
16
|
+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
17
|
+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
|
18
|
+
npm install -g yarn@$YARN_VERSION && \
|
19
|
+
rm -rf /tmp/node-build-master
|
18
20
|
<% end -%>
|
19
21
|
<% if yarn_version -%>
|
20
22
|
<% if yarn_version < '2' -%>
|
@@ -27,4 +29,4 @@ RUN corepack enable && \
|
|
27
29
|
<% end -%>
|
28
30
|
corepack prepare yarn@$YARN_VERSION --activate
|
29
31
|
<% end -%>
|
30
|
-
<% end -%>
|
32
|
+
<% end -%>
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# configure nginx
|
2
2
|
RUN gem install foreman && \
|
3
|
+
<% unless run_as_root? -%>
|
4
|
+
sed -i 's|pid /run|pid /rails/tmp/pids|' /etc/nginx/nginx.conf && \
|
5
|
+
<% end -%>
|
3
6
|
sed -i 's/access_log\s.*;/access_log \/dev\/stdout;/' /etc/nginx/nginx.conf && \
|
4
7
|
sed -i 's/error_log\s.*;/error_log \/dev\/stderr info;/' /etc/nginx/nginx.conf
|
5
8
|
|
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.
|
4
|
+
version: 1.2.0
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|