dockerfile-rails 1.4.2 → 1.5.1
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/README.md +16 -0
- data/lib/dockerfile-rails/scanner.rb +6 -2
- data/lib/generators/dockerfile_generator.rb +157 -34
- data/lib/generators/templates/Dockerfile.erb +30 -4
- data/lib/generators/templates/_install_node.erb +1 -1
- data/lib/generators/templates/_passenger.erb +1 -0
- data/lib/generators/templates/docker-compose.yml.erb +8 -0
- data/lib/generators/templates/docker-entrypoint.erb +4 -2
- data/lib/generators/templates/fly.toml.erb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aca228134c031de432e9c059c2451da36827f11334c25498506e1dc1a5f7819
|
4
|
+
data.tar.gz: b661bfc9e1d9a3aafa0a10181a33927616e06162bb4ea24f960d33ff5598337c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b432aedcdafad7b3aea076ad4501252aa2dc51f3cd980be1e6d4761d43b57773ec76ebc862d4f9cdd8526f1d5e3cf77c5f24b48d615fe558e0055b54aabd0803
|
7
|
+
data.tar.gz: c20b0900280252cef4eab686b3f0b2718e99e46779504174fd4898d86ec68868607acc1cc5179d5c815334c2d911e0bd587169dfe6ca023af40e2caa743f66fc
|
data/README.md
CHANGED
@@ -75,11 +75,27 @@ Not all of your needs can be determined by scanning your application. For examp
|
|
75
75
|
[autocrlf](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf) enabled or may not be able to set bin stubs as executable.
|
76
76
|
* `--label=name:value` - specify docker label. Can be used multiple times. See [LABEL](https://docs.docker.com/engine/reference/builder/#label) for detail
|
77
77
|
* `--no-prepare` - omit `db:prepare`. Useful for cloud platforms with [release](https://devcenter.heroku.com/articles/release-phase) phases
|
78
|
+
* `--passenger` - use [Phusion Passenger](https://www.phusionpassenger.com/) under [nginx](https://www.nginx.com/)
|
78
79
|
* `--platform=s` - specify target platform. See [FROM](https://docs.docker.com/engine/reference/builder/#from) for details
|
80
|
+
* `--variant=s` - dockerhub ruby variant, defaults to `slim`. See [docker official images](https://hub.docker.com/_/ruby) for list.
|
79
81
|
* `--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.
|
80
82
|
* `--root` - run application as root
|
81
83
|
* `--windows` - make Dockerfile work for Windows users that may have set `git config --global core.autocrlf true`
|
82
84
|
|
85
|
+
### Advanced Customization:
|
86
|
+
|
87
|
+
There may be times where feature detection plus flags just aren't enough. As an example, you may wish to configure and run multiple processes.
|
88
|
+
|
89
|
+
* `--instructions=path` - a dockerfile fragment to be inserted into the final document.
|
90
|
+
* `--migration=cmd` - a replacement (generally a script) for `db:prepare`/`db:migrate`.
|
91
|
+
* `--procfile=path` - a [Procfile](https://github.com/ddollar/foreman#foreman) to use in place of launching Rails directly.
|
92
|
+
|
93
|
+
Like with environment variables, packages, and build args, `--instructions` can be tailored to a specific build phase by adding `-base`, `-build`, or `-deploy` after the flag name, with the default being `-deploy`.
|
94
|
+
|
95
|
+
Additionaly, if the instructions start with a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) instead the file being treated as a Dockerfile fragment, the file is treated as a script and a `RUN` statement is added to your Dockerfile instead.
|
96
|
+
|
97
|
+
---
|
98
|
+
|
83
99
|
Options are saved between runs into `config/dockerfile.yml`. To invert a boolean options, add or remove a `no-` prefix from the option name.
|
84
100
|
|
85
101
|
## Testing
|
@@ -44,7 +44,7 @@ module DockerfileRails
|
|
44
44
|
@sqlite3 = true
|
45
45
|
elsif database == "postgresql"
|
46
46
|
@postgresql = true
|
47
|
-
elsif (database == "mysql") || (database == "mysql2")
|
47
|
+
elsif (database == "mysql") || (database == "mysql2") || (database == "trilogy")
|
48
48
|
@mysql = true
|
49
49
|
elsif database == "sqlserver"
|
50
50
|
@sqlserver = true
|
@@ -52,7 +52,7 @@ module DockerfileRails
|
|
52
52
|
|
53
53
|
@sqlite3 = true if @gemfile.include? "sqlite3"
|
54
54
|
@postgresql = true if @gemfile.include? "pg"
|
55
|
-
@mysql = true if @gemfile.include?
|
55
|
+
@mysql = true if @gemfile.include?("mysql2") || using_trilogy?
|
56
56
|
|
57
57
|
### node modules ###
|
58
58
|
|
@@ -81,5 +81,9 @@ module DockerfileRails
|
|
81
81
|
|
82
82
|
@redis = @redis_cable || @redis_cache
|
83
83
|
end
|
84
|
+
|
85
|
+
def using_trilogy?
|
86
|
+
@gemfile.include?("trilogy") || @gemfile.include?("activerecord-trilogy-adapter")
|
87
|
+
end
|
84
88
|
end
|
85
89
|
end
|
@@ -19,6 +19,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
19
19
|
"litefs" => false,
|
20
20
|
"lock" => true,
|
21
21
|
"max-idle" => nil,
|
22
|
+
"migrate" => "",
|
22
23
|
"mysql" => false,
|
23
24
|
"nginx" => false,
|
24
25
|
"parallel" => false,
|
@@ -27,14 +28,17 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
27
28
|
"postgresql" => false,
|
28
29
|
"precompile" => nil,
|
29
30
|
"prepare" => true,
|
31
|
+
"procfile" => "",
|
30
32
|
"redis" => false,
|
33
|
+
"registry" => "",
|
31
34
|
"root" => false,
|
32
35
|
"sqlite3" => false,
|
33
36
|
"sudo" => false,
|
34
37
|
"swap" => nil,
|
38
|
+
"variant" => "slim",
|
35
39
|
"windows" => false,
|
36
40
|
"yjit" => false,
|
37
|
-
}.
|
41
|
+
}.yield_self { |hash| Struct.new(*hash.keys.map(&:to_sym)).new(*hash.values) }
|
38
42
|
|
39
43
|
OPTION_DEFAULTS = BASE_DEFAULTS.dup
|
40
44
|
|
@@ -42,6 +46,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
42
46
|
@@packages = { "base" => [], "build" => [], "deploy" => [] }
|
43
47
|
@@vars = { "base" => {}, "build" => {}, "deploy" => {} }
|
44
48
|
@@args = { "base" => {}, "build" => {}, "deploy" => {} }
|
49
|
+
@@instructions = { "base" => nil, "build" => nil, "deploy" => nil }
|
45
50
|
|
46
51
|
# load defaults from config file
|
47
52
|
if File.exist? "config/dockerfile.yml"
|
@@ -70,6 +75,12 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
78
|
+
if options[:instructions]
|
79
|
+
options[:instructions].each do |stage, value|
|
80
|
+
@@instructions[stage.to_s] = value
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
73
84
|
@@labels = options[:label].stringify_keys if options.include? :label
|
74
85
|
end
|
75
86
|
end
|
@@ -125,6 +136,12 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
125
136
|
class_option :platform, type: :string, default: OPTION_DEFAULTS.platform,
|
126
137
|
desc: "image platform (example: linux/arm64)"
|
127
138
|
|
139
|
+
class_option :registry, type: :string, default: OPTION_DEFAULTS.registry,
|
140
|
+
desc: "docker registry to use (example: registry.docker.com/library/)"
|
141
|
+
|
142
|
+
class_option :variant, type: :string, default: OPTION_DEFAULTS.variant,
|
143
|
+
desc: "dockerhub image variant (example: slim-bullseye)"
|
144
|
+
|
128
145
|
class_option :jemalloc, type: :boolean, default: OPTION_DEFAULTS.jemalloc,
|
129
146
|
desc: "use jemalloc alternative malloc implementation"
|
130
147
|
|
@@ -152,6 +169,13 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
152
169
|
class_option :sudo, type: :boolean, default: OPTION_DEFAULTS.sudo,
|
153
170
|
desc: "Install and configure sudo to enable running as rails with full environment"
|
154
171
|
|
172
|
+
class_option "migrate", type: :string, default: OPTION_DEFAULTS.migrate,
|
173
|
+
desc: "custom migration/db:prepare script"
|
174
|
+
|
175
|
+
class_option "procfile", type: :string, default: OPTION_DEFAULTS.procfile,
|
176
|
+
desc: "custom procfile to start services"
|
177
|
+
|
178
|
+
|
155
179
|
class_option "add-base", type: :array, default: [],
|
156
180
|
desc: "additional packages to install for both build and deploy"
|
157
181
|
|
@@ -191,6 +215,16 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
191
215
|
desc: "additional build arguments to set for deployment"
|
192
216
|
|
193
217
|
|
218
|
+
class_option "instructions-base", type: :string, default: "",
|
219
|
+
desc: "additional instructions to add to the base stage"
|
220
|
+
|
221
|
+
class_option "instructions-build", type: :string, default: "",
|
222
|
+
desc: "additional instructions to add to the build stage"
|
223
|
+
|
224
|
+
class_option "instructions-deploy", aliases: "--instructions", type: :string, default: "",
|
225
|
+
desc: "additional instructions to add to the final stage"
|
226
|
+
|
227
|
+
|
194
228
|
def generate_app
|
195
229
|
source_paths.push File.expand_path("./templates", __dir__)
|
196
230
|
|
@@ -216,11 +250,15 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
216
250
|
@@args[phase].merge! options["arg-#{phase}"]
|
217
251
|
@@args[phase].delete_if { |key, value| value.blank? }
|
218
252
|
@@args.delete phase if @@args[phase].empty?
|
253
|
+
|
254
|
+
@@instructions[phase] ||= options["instructions-#{phase}"]
|
255
|
+
@@instructions.delete phase if @@instructions[phase].empty?
|
219
256
|
end
|
220
257
|
|
221
258
|
@dockerfile_config["packages"] = @@packages
|
222
259
|
@dockerfile_config["envs"] = @@vars
|
223
260
|
@dockerfile_config["args"] = @@args
|
261
|
+
@dockerfile_config["instructions"] = @@instructions
|
224
262
|
|
225
263
|
scan_rails_app
|
226
264
|
|
@@ -244,14 +282,12 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
244
282
|
fly_attach_consul
|
245
283
|
end
|
246
284
|
|
247
|
-
if
|
285
|
+
if File.exist?("fly.toml") && (fly_processes || !options.prepare)
|
248
286
|
if File.stat("fly.toml").size > 0
|
249
287
|
template "fly.toml.erb", "fly.toml"
|
250
288
|
else
|
251
|
-
toml =
|
252
|
-
if toml !=
|
253
|
-
File.write "fly.toml", toml
|
254
|
-
end
|
289
|
+
toml = fly_make_toml
|
290
|
+
File.write "fly.toml", toml if toml != ""
|
255
291
|
end
|
256
292
|
end
|
257
293
|
|
@@ -267,7 +303,7 @@ class DockerfileGenerator < Rails::Generators::Base
|
|
267
303
|
end
|
268
304
|
|
269
305
|
@dockerfile_config = (@dockerfile_config.to_a - BASE_DEFAULTS.to_h.stringify_keys.to_a).to_h
|
270
|
-
%w(packages envs args).each do |key|
|
306
|
+
%w(packages envs args instructions).each do |key|
|
271
307
|
@dockerfile_config.delete key if @dockerfile_config[key].empty?
|
272
308
|
end
|
273
309
|
|
@@ -283,7 +319,7 @@ private
|
|
283
319
|
scope = (Class.new do
|
284
320
|
def initialize(obj, locals)
|
285
321
|
@_obj = obj
|
286
|
-
@_locals = locals.
|
322
|
+
@_locals = locals.yield_self do |hash|
|
287
323
|
return nil if hash.empty?
|
288
324
|
Struct.new(*hash.keys.map(&:to_sym)).new(*hash.values)
|
289
325
|
end
|
@@ -362,6 +398,14 @@ private
|
|
362
398
|
using_node? && options.parallel
|
363
399
|
end
|
364
400
|
|
401
|
+
def has_mysql_gem?
|
402
|
+
@gemfile.include? "mysql2" or using_trilogy?
|
403
|
+
end
|
404
|
+
|
405
|
+
def using_trilogy?
|
406
|
+
@gemfile.include?("trilogy") || @gemfile.include?("activerecord-trilogy-adapter")
|
407
|
+
end
|
408
|
+
|
365
409
|
def keeps?
|
366
410
|
return @keeps if @keeps != nil
|
367
411
|
@keeps = !!Dir["**/.keep"]
|
@@ -381,7 +425,7 @@ private
|
|
381
425
|
end
|
382
426
|
|
383
427
|
if options.mysql? || @mysql
|
384
|
-
system "bundle add mysql2 --skip-install" unless
|
428
|
+
system "bundle add mysql2 --skip-install" unless has_mysql_gem?
|
385
429
|
end
|
386
430
|
|
387
431
|
if options.redis? || using_redis?
|
@@ -451,6 +495,9 @@ private
|
|
451
495
|
packages += %w(libjpeg-dev libpng-dev libtiff-dev libwebp-dev)
|
452
496
|
end
|
453
497
|
|
498
|
+
# Passenger
|
499
|
+
packages << "passenger" if using_passenger?
|
500
|
+
|
454
501
|
packages.sort.uniq
|
455
502
|
end
|
456
503
|
|
@@ -470,7 +517,10 @@ private
|
|
470
517
|
# add databases: sqlite3, postgres, mysql
|
471
518
|
packages << "pkg-config" if options.sqlite3? || @sqlite3
|
472
519
|
packages << "libpq-dev" if options.postgresql? || @postgresql
|
473
|
-
|
520
|
+
|
521
|
+
if (options.mysql? || @mysql) && !using_trilogy?
|
522
|
+
packages << "default-libmysqlclient-dev"
|
523
|
+
end
|
474
524
|
|
475
525
|
# add git if needed to install gems
|
476
526
|
packages << "git" if @git
|
@@ -516,10 +566,12 @@ private
|
|
516
566
|
packages += @@packages["deploy"] if @@packages["deploy"]
|
517
567
|
|
518
568
|
# start with databases: sqlite3, postgres, mysql
|
519
|
-
packages << "libsqlite3-0" if options.sqlite3? || @sqlite3
|
520
569
|
packages << "postgresql-client" if options.postgresql? || @postgresql
|
521
570
|
packages << "default-mysql-client" if options.mysql? || @mysql
|
522
571
|
packages << "libjemalloc2" if options.jemalloc? && !options.fullstaq?
|
572
|
+
if options.sqlite3? || @sqlite3
|
573
|
+
packages << "libsqlite3-0" unless packages.include? "sqlite3"
|
574
|
+
end
|
523
575
|
|
524
576
|
# litefs
|
525
577
|
packages += ["ca-certificates", "fuse3", "sudo"] if options.litefs?
|
@@ -542,7 +594,7 @@ private
|
|
542
594
|
end
|
543
595
|
|
544
596
|
# Passenger
|
545
|
-
packages
|
597
|
+
packages << "libnginx-mod-http-passenger" if using_passenger?
|
546
598
|
|
547
599
|
# nginx
|
548
600
|
packages << "nginx" if options.nginx? || using_passenger?
|
@@ -550,28 +602,49 @@ private
|
|
550
602
|
# sudo
|
551
603
|
packages << "sudo" if options.sudo?
|
552
604
|
|
605
|
+
if !options.procfile.blank? || (procfile.size > 1)
|
606
|
+
packages << "ruby-foreman"
|
607
|
+
end
|
608
|
+
|
553
609
|
packages.sort
|
554
610
|
end
|
555
611
|
|
556
|
-
def
|
612
|
+
def base_repos
|
557
613
|
repos = []
|
558
614
|
packages = []
|
559
615
|
|
560
|
-
if
|
616
|
+
if using_passenger?
|
561
617
|
packages += %w(gnupg curl)
|
562
618
|
repos += [
|
563
619
|
"curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt |",
|
564
|
-
" gpg --dearmor > /etc/apt/trusted.gpg.d/
|
565
|
-
'echo
|
620
|
+
" gpg --dearmor > /etc/apt/trusted.gpg.d/phusion.gpg &&",
|
621
|
+
"bash -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger $(source /etc/os-release; echo $VERSION_CODENAME) main > /etc/apt/sources.list.d/passenger.list'"
|
566
622
|
]
|
567
623
|
end
|
568
624
|
|
569
|
-
if
|
625
|
+
if repos.empty?
|
626
|
+
""
|
627
|
+
else
|
628
|
+
packages.sort!.uniq!
|
629
|
+
unless packages.empty?
|
630
|
+
repos.unshift "apt-get update -qq &&",
|
631
|
+
"apt-get install --no-install-recommends -y #{packages.join(" ")} &&"
|
632
|
+
end
|
633
|
+
|
634
|
+
repos.join(" \\\n ") + " && \\\n "
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
def deploy_repos
|
639
|
+
repos = []
|
640
|
+
packages = []
|
641
|
+
|
642
|
+
if using_puppeteer? && deploy_packages.include?("google-chrome-stable")
|
570
643
|
packages += %w(gnupg curl)
|
571
644
|
repos += [
|
572
|
-
"curl https://
|
573
|
-
" gpg --dearmor > /etc/apt/trusted.gpg.d/
|
574
|
-
|
645
|
+
"curl https://dl-ssl.google.com/linux/linux_signing_key.pub |",
|
646
|
+
" gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&",
|
647
|
+
'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
|
575
648
|
]
|
576
649
|
end
|
577
650
|
|
@@ -674,7 +747,7 @@ private
|
|
674
747
|
env.merge! @@args["deploy"].to_h { |key, value| [key, "$#{key}"] }
|
675
748
|
end
|
676
749
|
|
677
|
-
env.merge! @@vars["
|
750
|
+
env.merge! @@vars["deploy"] if @@vars["deploy"]
|
678
751
|
|
679
752
|
env.map { |key, value| "#{key}=#{value.inspect}" }.sort
|
680
753
|
end
|
@@ -718,6 +791,42 @@ private
|
|
718
791
|
args
|
719
792
|
end
|
720
793
|
|
794
|
+
def base_instructions
|
795
|
+
return nil unless @@instructions["base"]
|
796
|
+
|
797
|
+
instructions = IO.read @@instructions["base"]
|
798
|
+
|
799
|
+
if instructions.start_with? "#!"
|
800
|
+
instructions = "# custom instructions\nRUN #{@instructions["base"].strip}"
|
801
|
+
end
|
802
|
+
|
803
|
+
instructions.html_safe
|
804
|
+
end
|
805
|
+
|
806
|
+
def build_instructions
|
807
|
+
return nil unless @@instructions["build"]
|
808
|
+
|
809
|
+
instructions = IO.read @@instructions["build"]
|
810
|
+
|
811
|
+
if instructions.start_with? "#!"
|
812
|
+
instructions = "# custom build instructions\nRUN #{@instructions["build"].strip}"
|
813
|
+
end
|
814
|
+
|
815
|
+
instructions.html_safe
|
816
|
+
end
|
817
|
+
|
818
|
+
def deploy_instructions
|
819
|
+
return nil unless @@instructions["deploy"]
|
820
|
+
|
821
|
+
instructions = IO.read @@instructions["deploy"]
|
822
|
+
|
823
|
+
if instructions.start_with? "#!"
|
824
|
+
instructions = "# custom deploy instructions\nRUN #{@instructions["deploy"].strip}"
|
825
|
+
end
|
826
|
+
|
827
|
+
instructions.html_safe
|
828
|
+
end
|
829
|
+
|
721
830
|
def binfile_fixups
|
722
831
|
# binfiles may have OS specific paths to ruby. Normalize them.
|
723
832
|
shebangs = Dir["bin/*"].map { |file| IO.read(file).lines.first }.join
|
@@ -757,7 +866,7 @@ private
|
|
757
866
|
# use presence of "pg" or "mysql2" in the bundle as evidence of intent.
|
758
867
|
if options.postgresql? || @postgresql || @gemfile.include?("pg")
|
759
868
|
"postgresql"
|
760
|
-
elsif options.mysql? || @mysql ||
|
869
|
+
elsif options.mysql? || @mysql || has_mysql_gem?
|
761
870
|
"mysql"
|
762
871
|
else
|
763
872
|
"sqlite3"
|
@@ -838,10 +947,12 @@ private
|
|
838
947
|
end
|
839
948
|
|
840
949
|
def dbprep_command
|
841
|
-
if
|
842
|
-
|
950
|
+
if !options.migrate.blank?
|
951
|
+
options.migrate
|
952
|
+
elsif Rails::VERSION::MAJOR >= 6
|
953
|
+
"./bin/rails db:prepare"
|
843
954
|
else
|
844
|
-
"db:migrate"
|
955
|
+
"./bin/rails db:migrate"
|
845
956
|
end
|
846
957
|
end
|
847
958
|
|
@@ -940,19 +1051,31 @@ private
|
|
940
1051
|
system "#{flyctl} consul attach"
|
941
1052
|
end
|
942
1053
|
|
943
|
-
def
|
1054
|
+
def fly_make_toml
|
944
1055
|
toml = File.read("fly.toml")
|
945
1056
|
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
1057
|
+
list = fly_processes
|
1058
|
+
if list
|
1059
|
+
if toml.include? "[processes]"
|
1060
|
+
toml.sub!(/\[processes\].*?(\n\n|\n?\z)/m, "[processes]\n" +
|
1061
|
+
list.map { |name, cmd| " #{name} = #{cmd.inspect}" }.join("\n") + '\1')
|
1062
|
+
else
|
1063
|
+
toml += "\n[processes]\n" +
|
1064
|
+
list.map { |name, cmd| " #{name} = #{cmd.inspect}\n" }.join
|
952
1065
|
|
953
|
-
|
1066
|
+
app = list.has_key?("app") ? "app" : list.keys.first
|
954
1067
|
|
955
|
-
|
1068
|
+
toml.sub! "[http_service]\n", "\\0 processes = [#{app.inspect}]\n"
|
1069
|
+
end
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
if options.prepare == false
|
1073
|
+
deploy = "[deploy]\n release_command = #{dbprep_command.inspect}\n\n"
|
1074
|
+
if toml.include? "[deploy]"
|
1075
|
+
toml.sub!(/\[deploy\].*?(\n\n|\n?\z)/m, deploy)
|
1076
|
+
else
|
1077
|
+
toml += deploy
|
1078
|
+
end
|
956
1079
|
end
|
957
1080
|
|
958
1081
|
toml
|
@@ -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-' : ''
|
11
|
+
FROM <%= platform %>quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-<%= options.jemalloc ? 'jemalloc-' : '' %><%= options.variant %><% unless options.precompile == "defer" %> as base<% end %>
|
12
12
|
<% else -%>
|
13
|
-
FROM <%= platform %>
|
13
|
+
FROM <%= platform %><%= options.registry %>ruby:$RUBY_VERSION-<%= options.variant %><% unless options.precompile == "defer" %> as base<% end %>
|
14
14
|
<% end -%>
|
15
15
|
|
16
16
|
<% unless options.label.empty? -%>
|
@@ -36,12 +36,16 @@ RUN gem update --system --no-document && \
|
|
36
36
|
|
37
37
|
<% unless base_requirements.empty? -%>
|
38
38
|
# Install packages needed to install <%= base_requirements %>
|
39
|
-
<%= render partial: 'apt_install', locals: {packages: base_packages, clean: true, repos:
|
39
|
+
<%= render partial: 'apt_install', locals: {packages: base_packages, clean: true, repos: base_repos} %>
|
40
40
|
|
41
41
|
<% end -%>
|
42
42
|
<% if using_execjs? -%>
|
43
43
|
<%= render partial: 'install_node', locals: {yarn_version: nil} %>
|
44
44
|
|
45
|
+
<% end -%>
|
46
|
+
<% if base_instructions -%>
|
47
|
+
<%= base_instructions %>
|
48
|
+
|
45
49
|
<% end -%>
|
46
50
|
<% unless options.precompile == "defer" -%>
|
47
51
|
|
@@ -98,10 +102,17 @@ RUN bundle install<% if depend_on_bootsnap? -%> && \
|
|
98
102
|
bundle exec bootsnap precompile --gemfile<% end %> && \
|
99
103
|
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
|
100
104
|
|
105
|
+
<% end -%>
|
106
|
+
<% if using_passenger? -%>
|
107
|
+
# Compile passenger native support
|
108
|
+
RUN passenger-config build-native-support
|
109
|
+
|
101
110
|
<% end -%>
|
102
111
|
<% if parallel? -%>
|
103
112
|
# Copy node modules
|
104
113
|
COPY --from=node /rails/node_modules /rails/node_modules
|
114
|
+
COPY --from=node /usr/local/node /usr/local/node
|
115
|
+
ENV PATH=/usr/local/node/bin:$PATH
|
105
116
|
|
106
117
|
<% elsif using_node? -%>
|
107
118
|
<%= render partial: 'npm_install', locals: {sources: Dir[*%w(package.json package-lock.json yarn.lock)]} %>
|
@@ -110,6 +121,10 @@ COPY --from=node /rails/node_modules /rails/node_modules
|
|
110
121
|
# Copy application code
|
111
122
|
COPY<% if options.link? %> --link<% end %> . .
|
112
123
|
|
124
|
+
<% if build_instructions -%>
|
125
|
+
<%= build_instructions %>
|
126
|
+
|
127
|
+
<% end -%>
|
113
128
|
<% if depend_on_bootsnap? -%>
|
114
129
|
# Precompile bootsnap code for faster boot times
|
115
130
|
RUN bundle exec bootsnap precompile app/ lib/
|
@@ -165,6 +180,11 @@ RUN gem install foreman
|
|
165
180
|
# Copy built artifacts: gems, application
|
166
181
|
COPY --from=build /usr/local/bundle /usr/local/bundle
|
167
182
|
COPY --from=build /rails /rails
|
183
|
+
<% if using_passenger? -%>
|
184
|
+
|
185
|
+
# Copy passenger native support
|
186
|
+
COPY --from=build /root/.passenger/native_support /root/.passenger/native_support
|
187
|
+
<% end -%>
|
168
188
|
<% if api_client_dir -%>
|
169
189
|
|
170
190
|
# Copy built client
|
@@ -202,6 +222,10 @@ RUN useradd rails --create-home --shell /bin/bash && \
|
|
202
222
|
USER rails:rails
|
203
223
|
<% end -%>
|
204
224
|
|
225
|
+
<% end -%>
|
226
|
+
<% if deploy_instructions -%>
|
227
|
+
<%= deploy_instructions.strip %>
|
228
|
+
|
205
229
|
<% end -%>
|
206
230
|
<% if using_litefs? and !run_as_root? -%>
|
207
231
|
# Authorize rails user to launch litefs
|
@@ -237,7 +261,9 @@ EXPOSE 3000
|
|
237
261
|
VOLUME /data
|
238
262
|
<% end -%>
|
239
263
|
<% unless fly_processes -%>
|
240
|
-
<% if procfile.
|
264
|
+
<% if !options.procfile.blank? -%>
|
265
|
+
CMD ["foreman", "start", "--procfile=<%= options.procfile %>"]
|
266
|
+
<% elsif procfile.size > 1 -%>
|
241
267
|
CMD ["foreman", "start", "--procfile=Procfile.prod"]
|
242
268
|
<% else -%>
|
243
269
|
CMD <%= procfile.values.first.split(" ").inspect %>
|
@@ -20,7 +20,7 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
|
|
20
20
|
<% if yarn_version < '2' -%>
|
21
21
|
<% if node_version -%> <% else %>RUN<% end %> npm install -g yarn@$YARN_VERSION<% if node_version -%> && \<% end %>
|
22
22
|
<% else -%>
|
23
|
-
<% if (node_version.split('.').map(&:to_i) <=> [16,10,0]) < 0 -%>
|
23
|
+
<% if node_version && (node_version.split('.').map(&:to_i) <=> [16,10,0]) < 0 -%>
|
24
24
|
npm i -g corepack && \
|
25
25
|
<% else -%>
|
26
26
|
corepack enable && \
|
@@ -21,8 +21,12 @@ services:
|
|
21
21
|
<% if deploy_database == 'postgresql' -%>
|
22
22
|
- DATABASE_URL=postgres://root:password@postgres-db/
|
23
23
|
<% elsif deploy_database == 'mysql' -%>
|
24
|
+
<% if using_trilogy? -%>
|
25
|
+
- DATABASE_URL=trilogy://root:password@mysql-db/
|
26
|
+
<% else -%>
|
24
27
|
- DATABASE_URL=mysql2://root:password@mysql-db/
|
25
28
|
<% end -%>
|
29
|
+
<% end -%>
|
26
30
|
<% if deploy_database == 'sqlite3' -%>
|
27
31
|
volumes:
|
28
32
|
- ./db:/rails/db
|
@@ -89,7 +93,11 @@ services:
|
|
89
93
|
<% if deploy_database == 'postgresql' -%>
|
90
94
|
- DATABASE_URL=postgres://root:password@postgres-db/
|
91
95
|
<% elsif deploy_database == 'mysql' -%>
|
96
|
+
<% if using_trilogy? -%>
|
97
|
+
- DATABASE_URL=trilogy://root:password@mysql-db/
|
98
|
+
<% else -%>
|
92
99
|
- DATABASE_URL=mysql2://root:password@mysql-db/
|
100
|
+
<% end -%>
|
93
101
|
<% end -%>
|
94
102
|
depends_on:
|
95
103
|
redis-db:
|
@@ -31,7 +31,9 @@ fi
|
|
31
31
|
|
32
32
|
<% end -%>
|
33
33
|
<% if options.prepare -%>
|
34
|
-
<% if procfile.
|
34
|
+
<% if !options.procfile.blank? -%>
|
35
|
+
if [ "${*}" == "foreman start --procfile=<%= options.procfile %>" ]; then
|
36
|
+
<% elsif procfile.size > 1 -%>
|
35
37
|
# If running the production procfile then create or migrate existing database
|
36
38
|
if [ "${*}" == "foreman start --procfile=Procfile.prod" ]; then
|
37
39
|
<% else -%>
|
@@ -41,7 +43,7 @@ if [ "${*}" == <%= procfile.values.first.inspect %> <% if using_litefs? %>-a "$F
|
|
41
43
|
<% if options.precompile == "defer" -%>
|
42
44
|
./bin/rails assets:precompile
|
43
45
|
<% end -%>
|
44
|
-
|
46
|
+
<%= dbprep_command %>
|
45
47
|
fi
|
46
48
|
|
47
49
|
<% elsif !options.swap -%>
|
@@ -1 +1 @@
|
|
1
|
-
<%=
|
1
|
+
<%= fly_make_toml -%>
|
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.5.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-
|
11
|
+
date: 2023-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -65,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.6.0
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|