dockerfile-rails 1.5.3 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/generators/dockerfile_generator.rb +21 -1
- data/lib/generators/templates/Dockerfile.erb +16 -3
- data/lib/generators/templates/_install_node.erb +2 -2
- data/lib/generators/templates/_npm_install.erb +3 -0
- data/lib/generators/templates/docker-compose.yml.erb +14 -0
- data/lib/generators/templates/dockerignore.erb +5 -2
- 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: 887b4d62bfcefd69fb9a4d439c0b5ba04b99b56cf907206225a5d9fdabf387bf
|
4
|
+
data.tar.gz: 312fe0d83b1e162dfcc4759740db463c272278f4ac49384550678a8416c652bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4acd6d209416af9d4144ff9acb4c06337f4ca1084c8a739562f2369ade04b9f8402191622733be22cc6f3eac9f3312d814096e0bbdfb77da10669a61e5170262
|
7
|
+
data.tar.gz: e4b2ad3fc68756f2926b919bb461019e1f3568fd7ae4e55ea83c2626b8dc574a42176ab758ae63beb19012ffebe6a004daca8dbfb32dd9ab46e06df3b0c810ad
|
data/README.md
CHANGED
@@ -85,6 +85,7 @@ Not all of your needs can be determined by scanning your application. For examp
|
|
85
85
|
* `--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.
|
86
86
|
* `--root` - run application as root
|
87
87
|
* `--windows` - make Dockerfile work for Windows users that may have set `git config --global core.autocrlf true`
|
88
|
+
* `--private-gemserver-domain=gems.example.com` - set the domain name of your private gemserver. This is used to tell bundler for what domain to use the credentials of a private gemserver provided via a docker secret
|
88
89
|
|
89
90
|
### Advanced Customization:
|
90
91
|
|
@@ -119,7 +120,7 @@ rake test
|
|
119
120
|
ruby test/test_minimal.rb
|
120
121
|
```
|
121
122
|
|
122
|
-
To
|
123
|
+
To assist with this process, outputs of tests can be captured automatically. This is useful when adding new tests and when making a change that affects many tests. Be sure to inspect the output (e.g., by using `git diff`) before committing.
|
123
124
|
|
124
125
|
```
|
125
126
|
rake test:capture
|
@@ -28,6 +28,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
28
28
|
"postgresql" => false,
|
29
29
|
"precompile" => nil,
|
30
30
|
"prepare" => true,
|
31
|
+
"private-gemserver-domain" => nil,
|
31
32
|
"procfile" => "",
|
32
33
|
"redis" => false,
|
33
34
|
"registry" => "",
|
@@ -183,6 +184,9 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
183
184
|
class_option "procfile", type: :string, default: OPTION_DEFAULTS.procfile,
|
184
185
|
desc: "custom procfile to start services"
|
185
186
|
|
187
|
+
class_option "private-gemserver-domain", type: :string, default: OPTION_DEFAULTS["private-gemserver-domain"],
|
188
|
+
desc: "domain name of a private gemserver used when installing application gems"
|
189
|
+
|
186
190
|
|
187
191
|
class_option "add-base", type: :array, default: [],
|
188
192
|
desc: "additional packages to install for both build and deploy"
|
@@ -538,6 +542,7 @@ private
|
|
538
542
|
# start with the essentials
|
539
543
|
packages = %w(build-essential)
|
540
544
|
packages += @@packages["build"] if @@packages["build"]
|
545
|
+
packages += %w(nodejs npm) if node_version == "lts"
|
541
546
|
|
542
547
|
# add databases: sqlite3, postgres, mysql
|
543
548
|
packages << "pkg-config" if options.sqlite3? || @sqlite3
|
@@ -849,7 +854,9 @@ private
|
|
849
854
|
|
850
855
|
def binfile_fixups
|
851
856
|
# binfiles may have OS specific paths to ruby. Normalize them.
|
852
|
-
shebangs = Dir["bin/*"].map
|
857
|
+
shebangs = Dir["bin/*"].map do |file|
|
858
|
+
IO.read(file).lines.first.encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "")
|
859
|
+
end.join
|
853
860
|
rubies = shebangs.scan(%r{#!/usr/bin/env (ruby.*)}).flatten.uniq
|
854
861
|
|
855
862
|
binfixups = (rubies - %w(ruby)).map do |ruby|
|
@@ -1039,6 +1046,19 @@ private
|
|
1039
1046
|
nil
|
1040
1047
|
end
|
1041
1048
|
|
1049
|
+
# Takes the domain of the private gemserver and returns the name of the
|
1050
|
+
# environment variable, as expected by bundler.
|
1051
|
+
#
|
1052
|
+
# For example, if the domain is "gems.example.com", the environment variable
|
1053
|
+
# name will be "BUNDLE_GEMS__EXAMPLE__COM".
|
1054
|
+
def private_gemserver_env_variable_name
|
1055
|
+
option = options["private-gemserver-domain"]
|
1056
|
+
|
1057
|
+
return nil if option.blank?
|
1058
|
+
|
1059
|
+
"BUNDLE_#{option.upcase.gsub(".", "__")}"
|
1060
|
+
end
|
1061
|
+
|
1042
1062
|
# if running on fly v2, make a best effort to attach consul
|
1043
1063
|
def fly_attach_consul
|
1044
1064
|
# certainly not fly unless there is a fly.toml
|
@@ -86,10 +86,15 @@ ENV <%= build_env.join(" \\\n ") %>
|
|
86
86
|
COPY<% if options.link? %> --link<% end %> Gemfile Gemfile.lock ./
|
87
87
|
<% if options.cache? -%>
|
88
88
|
RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor \
|
89
|
+
<% if private_gemserver_env_variable_name -%>
|
90
|
+
--mount=type=secret,id=gemserver_credentials,dst=/kaniko/gemserver_credentials \
|
91
|
+
<%= private_gemserver_env_variable_name %>="$(cat /kaniko/gemserver_credentials)" && \
|
92
|
+
export <%= private_gemserver_env_variable_name %> && \
|
93
|
+
<% end -%>
|
89
94
|
bundle config set app_config .bundle && \
|
90
95
|
bundle config set path /srv/vendor && \
|
91
96
|
bundle install && \
|
92
|
-
<% if depend_on_bootsnap? -%>
|
97
|
+
<% if depend_on_bootsnap? && options.precompile != "defer" -%>
|
93
98
|
bundle exec bootsnap precompile --gemfile && \
|
94
99
|
<% end -%>
|
95
100
|
bundle clean && \
|
@@ -98,8 +103,16 @@ RUN --mount=type=cache,id=bld-gem-cache,sharing=locked,target=/srv/vendor \
|
|
98
103
|
cp -ar /srv/vendor .
|
99
104
|
|
100
105
|
<% else -%>
|
101
|
-
|
106
|
+
<% if private_gemserver_env_variable_name -%>
|
107
|
+
RUN --mount=type=secret,id=gemserver_credentials,dst=/kaniko/gemserver_credentials \
|
108
|
+
<%= private_gemserver_env_variable_name %>="$(cat /kaniko/gemserver_credentials)" && \
|
109
|
+
export <%= private_gemserver_env_variable_name %> && \
|
110
|
+
bundle install<% if depend_on_bootsnap? && options.precompile != "defer" -%> && \
|
102
111
|
bundle exec bootsnap precompile --gemfile<% end %> && \
|
112
|
+
<% else -%>
|
113
|
+
RUN bundle install<% if depend_on_bootsnap? && options.precompile != "defer" -%> && \
|
114
|
+
bundle exec bootsnap precompile --gemfile<% end %> && \
|
115
|
+
<% end -%>
|
103
116
|
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
|
104
117
|
|
105
118
|
<% end -%>
|
@@ -115,7 +128,7 @@ COPY --from=node /usr/local/node /usr/local/node
|
|
115
128
|
ENV PATH=/usr/local/node/bin:$PATH
|
116
129
|
|
117
130
|
<% elsif using_node? -%>
|
118
|
-
<%= render partial: 'npm_install', locals: {sources: Dir[*%w(package.json package-lock.json yarn.lock)]} %>
|
131
|
+
<%= render partial: 'npm_install', locals: {sources: Dir[*%w(.npmrc .yarnrc package.json package-lock.json yarn.lock)]} %>
|
119
132
|
|
120
133
|
<% end -%>
|
121
134
|
# Copy application code
|
@@ -5,13 +5,13 @@
|
|
5
5
|
<% elsif yarn_version -%>
|
6
6
|
# Install yarn
|
7
7
|
<% end -%>
|
8
|
-
<% if node_version -%>
|
8
|
+
<% if node_version && node_version != 'lts' -%>
|
9
9
|
ARG NODE_VERSION=<%= node_version %>
|
10
10
|
<% end -%>
|
11
11
|
<% if yarn_version -%>
|
12
12
|
ARG YARN_VERSION=<%= yarn_version %>
|
13
13
|
<% end -%>
|
14
|
-
<% if node_version -%>
|
14
|
+
<% if node_version && node_version != 'lts' -%>
|
15
15
|
ENV PATH=/usr/local/node/bin:$PATH
|
16
16
|
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
17
17
|
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# Install node modules
|
2
2
|
COPY<% if options.link? %> --link<% end %> <%= sources.join(' ') %> ./
|
3
|
+
<% if sources.join.include?('.yarnrc') && !Dir['.yarn/releases/*'].empty? -%>
|
4
|
+
COPY<% if options.link? %> --link<% end %> .yarn/releases/* .yarn/releases/
|
5
|
+
<% end -%>
|
3
6
|
<% if sources.join.include? 'yarn' -%>
|
4
7
|
RUN <% if options.cache? -%>--mount=type=cache,id=bld-yarn-cache,target=/root/.yarn \
|
5
8
|
YARN_CACHE_FOLDER=/root/.yarn <% end -%>yarn install<% if options.lock? %> --frozen-lockfile<% end %>
|
@@ -3,6 +3,10 @@ services:
|
|
3
3
|
web:
|
4
4
|
<% if all_args.empty? -%>
|
5
5
|
build: .
|
6
|
+
<% if private_gemserver_env_variable_name -%>
|
7
|
+
secrets:
|
8
|
+
- gemserver_credentials
|
9
|
+
<% end -%>
|
6
10
|
<% else -%>
|
7
11
|
build:
|
8
12
|
context: .
|
@@ -10,6 +14,10 @@ services:
|
|
10
14
|
<% all_args.each do |name, value| -%>
|
11
15
|
<%= name %>: <%= value.html_safe? ? value : "\"#{Shellwords.escape(value)}\"" %>
|
12
16
|
<% end -%>
|
17
|
+
<% if private_gemserver_env_variable_name -%>
|
18
|
+
secrets:
|
19
|
+
- gemserver_credentials
|
20
|
+
<% end -%>
|
13
21
|
<% end -%>
|
14
22
|
ports:
|
15
23
|
- "3000:3000"
|
@@ -110,3 +118,9 @@ services:
|
|
110
118
|
condition: service_healthy
|
111
119
|
<% end -%>
|
112
120
|
<% end -%>
|
121
|
+
<% if private_gemserver_env_variable_name -%>
|
122
|
+
|
123
|
+
secrets:
|
124
|
+
gemserver_credentials:
|
125
|
+
file: ./GEMSERVER_CREDENTIALS.secret.txt
|
126
|
+
<% end -%>
|
@@ -24,7 +24,6 @@
|
|
24
24
|
|
25
25
|
# Ignore pidfiles, but keep the directory.
|
26
26
|
/tmp/pids/*
|
27
|
-
!/tmp/pids/
|
28
27
|
<% if keeps? -%>
|
29
28
|
!/tmp/pids/.keep
|
30
29
|
<% end -%>
|
@@ -34,11 +33,15 @@
|
|
34
33
|
<% if keeps? -%>
|
35
34
|
!/storage/.keep
|
36
35
|
/tmp/storage/*
|
37
|
-
!/tmp/storage/
|
38
36
|
!/tmp/storage/.keep
|
39
37
|
<% end -%>
|
40
38
|
<% unless options.api? -%>
|
41
39
|
|
40
|
+
<% if private_gemserver_env_variable_name -%>
|
41
|
+
# Ignore gemserver credentials.
|
42
|
+
GEMSERVER_CREDENTIALS.secret.txt
|
43
|
+
|
44
|
+
<% end -%>
|
42
45
|
# Ignore assets.
|
43
46
|
/node_modules/
|
44
47
|
/app/assets/builds/*
|
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.5.
|
4
|
+
version: 1.5.5
|
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-
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|