dockerfile-rails 1.0.0 → 1.0.1
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: 3cf90509af5087378fd186d88358f0157d40ca2335e19a66ecdddbf1efd9add4
|
4
|
+
data.tar.gz: 640b5eeb291be5e4168a5da7ffd17236b1ebf49deed3fb8a5d8148e6fe3ba92c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9390f22b5e4348c6d59345b08c843bec8ae4932e6b20afa69bffac4bf600c3489ae093e9847b9f59cd0b688b448d35c4c5a1815743b2693abd90db97d051a7cd
|
7
|
+
data.tar.gz: 77fe857b46a6aa3b5bda4d7b3ce0f68b24f1907d1a049c927b4e2d0e759d39b2fd771ebf3b5937d92c418f4d3e04b52f07788d939b06d644a0d4f028fb9bd7c2
|
data/DEMO.md
CHANGED
@@ -275,3 +275,31 @@ bin/rails generate dockerfile
|
|
275
275
|
docker buildx build . -t rails-welcome
|
276
276
|
docker run -p 3000:3000 -e RAILS_MASTER_KEY=$(cat config/master.key) rails-welcome
|
277
277
|
```
|
278
|
+
|
279
|
+
# Demo 5 - Grover / puppeteer / Chrome
|
280
|
+
|
281
|
+
This demo runs only on Intel hardware as Google doesn't supply Chrome
|
282
|
+
binaries for Linux on ARM.
|
283
|
+
|
284
|
+
```bash
|
285
|
+
rails new welcome --minimal
|
286
|
+
cd welcome
|
287
|
+
bundle add grover
|
288
|
+
npm install puppeteer
|
289
|
+
|
290
|
+
echo 'Rails.application.routes.draw { root "grover#pdf" }' > config/routes.rb
|
291
|
+
|
292
|
+
cat << 'EOF' > app/controllers/grover_controller.rb
|
293
|
+
class GroverController < ApplicationController
|
294
|
+
def pdf
|
295
|
+
grover = Grover.new('https://google.com', format: 'A4')
|
296
|
+
send_data grover.to_pdf, filename: 'google.pdf', type: :pdf
|
297
|
+
end
|
298
|
+
end
|
299
|
+
EOF
|
300
|
+
|
301
|
+
bundle add dockerfile-rails --group development
|
302
|
+
bin/rails generate dockerfile
|
303
|
+
docker buildx build . -t rails-welcome
|
304
|
+
docker run -p 3000:3000 -e RAILS_MASTER_KEY=$(cat config/master.key) rails-welcome
|
305
|
+
```
|
@@ -146,7 +146,11 @@ private
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def using_execjs?
|
149
|
-
@gemfile.include?
|
149
|
+
@gemfile.include?('execjs') or @gemfile.include?('grover')
|
150
|
+
end
|
151
|
+
|
152
|
+
def using_puppeteer?
|
153
|
+
@gemfile.include?('grover')
|
150
154
|
end
|
151
155
|
|
152
156
|
def parallel?
|
@@ -238,9 +242,30 @@ private
|
|
238
242
|
# Rmagick gem
|
239
243
|
packages << 'imagemagick' if @gemfile.include? 'rmagick'
|
240
244
|
|
245
|
+
# Puppeteer
|
246
|
+
packages << 'google-chrome-stable' if using_puppeteer?
|
247
|
+
|
241
248
|
packages.sort
|
242
249
|
end
|
243
250
|
|
251
|
+
def deploy_repos
|
252
|
+
repos = []
|
253
|
+
|
254
|
+
if using_puppeteer?
|
255
|
+
repos += [
|
256
|
+
"curl https://dl-ssl.google.com/linux/linux_signing_key.pub |",
|
257
|
+
"gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&",
|
258
|
+
'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
|
259
|
+
]
|
260
|
+
end
|
261
|
+
|
262
|
+
if repos.empty?
|
263
|
+
''
|
264
|
+
else
|
265
|
+
repos.join(" \\\n ") + " && \\\n "
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
244
269
|
def deploy_env
|
245
270
|
env = []
|
246
271
|
|
@@ -263,6 +288,11 @@ private
|
|
263
288
|
env << 'MALLOC_CONF="dirty_decay_ms:1000,narenas:2,background_thread:true"'
|
264
289
|
end
|
265
290
|
|
291
|
+
if using_puppeteer?
|
292
|
+
env << 'GROVER_NO_SANDBOX="true"' if @gemfile.include? 'grover'
|
293
|
+
env << 'PUPPETEER_EXECUTABLE_PATH="/usr/bin/google-chrome"'
|
294
|
+
end
|
295
|
+
|
266
296
|
env
|
267
297
|
end
|
268
298
|
|
@@ -27,8 +27,13 @@ RUN gem update --system --no-document && \
|
|
27
27
|
gem install -N bundler -v ${BUNDLER_VERSION}
|
28
28
|
|
29
29
|
<% if using_execjs? -%>
|
30
|
+
<% if using_puppeteer? -%>
|
31
|
+
# Install packages needed to install nodejs and chrome
|
32
|
+
<%= render partial: 'apt_install', locals: {packages: %w(curl gnupg unzip), clean: true, repos: ''} %>
|
33
|
+
<% else -%>
|
30
34
|
# Install packages needed to install nodejs
|
31
|
-
<%= render partial: 'apt_install', locals: {packages: %w(curl unzip), clean: true} %>
|
35
|
+
<%= render partial: 'apt_install', locals: {packages: %w(curl unzip), clean: true, repos: ''} %>
|
36
|
+
<% end -%>
|
32
37
|
|
33
38
|
<%= render partial: 'install_node', locals: {yarn_version: nil} %>
|
34
39
|
|
@@ -38,15 +43,15 @@ RUN gem update --system --no-document && \
|
|
38
43
|
FROM base as <%= parallel? ? 'pre' : '' %>build
|
39
44
|
|
40
45
|
# Install packages needed to build gems<%= using_node? ? " and node modules" : "" %>
|
41
|
-
<%= render partial: 'apt_install', locals: {packages: build_packages, clean: false} %>
|
46
|
+
<%= render partial: 'apt_install', locals: {packages: build_packages, clean: false, repos: ''} %>
|
42
47
|
|
43
48
|
<% if parallel? -%>
|
44
49
|
|
45
50
|
FROM prebuild as node
|
46
51
|
|
47
52
|
<% end -%>
|
48
|
-
<% if using_node? -%>
|
49
|
-
<%= render partial: 'install_node', locals: {node_version: using_execjs? ? nil : node_version} %>
|
53
|
+
<% if using_node? and (!using_execjs? || File.exist?('yarn.lock')) -%>
|
54
|
+
<%= render partial: 'install_node', locals: {node_version: using_execjs? ? nil : node_version, yarn_version: File.exist?('yarn.lock') ? yarn_version : nil} %>
|
50
55
|
|
51
56
|
<% end -%>
|
52
57
|
<% if parallel? -%>
|
@@ -81,7 +86,7 @@ RUN bundle _${BUNDLER_VERSION}_ install<% if depend_on_bootsnap? -%> && \
|
|
81
86
|
COPY --from=node /rails/node_modules /rails/node_modules
|
82
87
|
|
83
88
|
<% elsif using_node? -%>
|
84
|
-
<%= render partial: 'npm_install', locals: {sources:
|
89
|
+
<%= render partial: 'npm_install', locals: {sources: Dir[*%w(package.json package-lock.json yarn.lock)]} %>
|
85
90
|
|
86
91
|
<% end -%>
|
87
92
|
# Copy application code
|
@@ -112,7 +117,7 @@ FROM base
|
|
112
117
|
<% unless deploy_packages.empty? -%>
|
113
118
|
|
114
119
|
# Install packages needed for deployment
|
115
|
-
<%= render partial: 'apt_install', locals: {packages: deploy_packages, clean: true} %>
|
120
|
+
<%= render partial: 'apt_install', locals: {packages: deploy_packages, clean: true, repos: deploy_repos} %>
|
116
121
|
<% end -%>
|
117
122
|
|
118
123
|
# Copy built application from previous stage
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% if options.cache? -%>
|
2
2
|
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
|
3
3
|
--mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt \
|
4
|
-
apt-get update -qq && \
|
4
|
+
<%= repos %>apt-get update -qq && \
|
5
5
|
apt-get install --no-install-recommends -y <%= packages.join(" ") %>
|
6
6
|
<% else -%>
|
7
|
-
RUN apt-get update -qq && \
|
7
|
+
RUN <%= repos %>apt-get update -qq && \
|
8
8
|
apt-get install --no-install-recommends -y <%= packages.join(" ") %><% if clean %> && \
|
9
9
|
rm -rf /var/lib/apt/lists /var/cache/apt/archives<% end %>
|
10
10
|
<% end -%>
|
@@ -17,4 +17,4 @@ RUN apt-get update -qq && \
|
|
17
17
|
make && \
|
18
18
|
make install
|
19
19
|
<% end -%>
|
20
|
-
|
20
|
+
|
@@ -1,4 +1,7 @@
|
|
1
1
|
# Install node modules
|
2
|
+
<% if using_puppeteer? -%>
|
3
|
+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
|
4
|
+
<% end -%>
|
2
5
|
COPY <%=sources.join(' ') %> .
|
3
6
|
<% if sources.join.include? 'yarn' -%>
|
4
7
|
<% if options.cache? -%>
|
@@ -14,4 +17,4 @@ RUN --mount=type=cache,id=bld-npm-cache,target=/root/.npm \
|
|
14
17
|
<% else -%>
|
15
18
|
RUN npm install
|
16
19
|
<% end -%>
|
17
|
-
<% end -%>
|
20
|
+
<% 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.1
|
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-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|