dockerfile-rails 1.4.0 → 1.4.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: 5d1b0d5e237b0a8c33a3b1263d34590db8912967420863332ad0b2c8f5661e5f
4
- data.tar.gz: 000fd8db20304bc2ba8623aaa1a4bd19870ec4143cacc3cb6ea31b8690510782
3
+ metadata.gz: 70cab322c4f52cdddb9934de220be781a87ef306af7a21bf1db8a15c8db16a3a
4
+ data.tar.gz: a8363fcbdd774e3a2b3254f274366c0ad0f700eabdc90502a189c727005de25e
5
5
  SHA512:
6
- metadata.gz: 64b8702f00462a318af21238617528682be3831da82471bff0172ef9ef98d7e4a6a10346ffe297e87e76cc5d4b2699bf56b79d9257f1eee3c8cc24bc56012037
7
- data.tar.gz: 9a9dc774d388e4276b08bbcdcce9ffd676800df7bb86b4cac34e6795fd0ee6f24ba2a57df393f7948f738a9bdafe8a1ed8073c0b91d9e6a2f9f94349a7d14fe4
6
+ metadata.gz: 10fe62c57fe8f2088bbe0b58feafc4199e2591cf214d39e410d1e78be3f5039187ee28ed9279f774eb02ec991bd46318a014fa324bfc57fe16c9398c51844e10
7
+ data.tar.gz: 9bcc4bca316a3c4eb96a00060e1f3cbc45072975a28c16248353947da1e9259121fdbf7213e3a382cd407f48a1eb0d1b3baec65a9461242f1269f376a887d291
@@ -244,6 +244,17 @@ class DockerfileGenerator < Rails::Generators::Base
244
244
  fly_attach_consul
245
245
  end
246
246
 
247
+ if fly_processes # therefore File.exist?('fly.toml')
248
+ if File.stat("fly.toml").size > 0
249
+ template "fly.toml.erb", "fly.toml"
250
+ else
251
+ toml = fly_make_processes(fly_processes)
252
+ if toml != IO.read("fly.toml")
253
+ File.write "fly.toml", toml
254
+ end
255
+ end
256
+ end
257
+
247
258
  if @gemfile.include?("vite_ruby")
248
259
  package = JSON.load_file("package.json")
249
260
  unless package.dig("scripts", "build")
@@ -851,6 +862,21 @@ private
851
862
  end
852
863
  end
853
864
 
865
+ def fly_processes
866
+ return unless File.exist? "fly.toml"
867
+ return unless using_sidekiq?
868
+
869
+ if procfile.size > 1
870
+ list = { "app" => "foreman start --procfile=Procfile.prod" }
871
+ else
872
+ list = { "app" => procfile.values.first }
873
+ end
874
+
875
+ list["sidekiq"] = "bundle exec sidekiq"
876
+
877
+ list
878
+ end
879
+
854
880
  def more_docker_ignores
855
881
  more = ""
856
882
 
@@ -902,11 +928,33 @@ private
902
928
  return unless flyctl
903
929
 
904
930
  # see if secret is already set?
905
- secrets = JSON.parse(`#{flyctl} secrets list --json`)
906
- return if secrets.any? { |secret| secret["Name"] == "FLY_CONSUL_URL" }
931
+ begin
932
+ secrets = JSON.parse(`#{flyctl} secrets list --json`)
933
+ return if secrets.any? { |secret| secret["Name"] == "FLY_CONSUL_URL" }
934
+ rescue
935
+ return # likely got an error like "Could not find App"
936
+ end
907
937
 
908
938
  # attach consul
909
- say_status "execute", "flyctl consul attach", :green
939
+ say_status :execute, "flyctl consul attach", :green
910
940
  system "#{flyctl} consul attach"
911
941
  end
942
+
943
+ def fly_make_processes(list)
944
+ toml = File.read("fly.toml")
945
+
946
+ if toml.include? "[processes]"
947
+ toml.sub!(/\[processes\].*?(\n\n|\n?\z)/m, "[processes]\n" +
948
+ list.map { |name, cmd| " #{name} = #{cmd.inspect}" }.join("\n") + '\1')
949
+ else
950
+ toml += "\n[processes]\n" +
951
+ list.map { |name, cmd| " #{name} = #{cmd.inspect}\n" }.join
952
+
953
+ app = list.has_key?("app") ? "app" : list.keys.first
954
+
955
+ toml.sub! "[http_service]\n", "\\0 processes = [#{app.inspect}]\n"
956
+ end
957
+
958
+ toml
959
+ end
912
960
  end
@@ -230,17 +230,16 @@ COPY <<-"EOF" /rails/Procfile.prod
230
230
  <% end -%>
231
231
  EOF
232
232
 
233
+ <% end -%>
233
234
  # Start the server by default, this can be overwritten at runtime
234
235
  EXPOSE 3000
235
236
  <% if deploy_database == 'sqlite3' -%>
236
237
  VOLUME /data
237
238
  <% end -%>
239
+ <% unless fly_processes -%>
240
+ <% if procfile.size > 1 -%>
238
241
  CMD ["foreman", "start", "--procfile=Procfile.prod"]
239
242
  <% else -%>
240
- # Start the server by default, this can be overwritten at runtime
241
- EXPOSE 3000
242
- <% if deploy_database == 'sqlite3' -%>
243
- VOLUME /data
244
- <% end -%>
245
243
  CMD <%= procfile.values.first.split(" ").inspect %>
246
244
  <% end -%>
245
+ <% end -%>
@@ -82,7 +82,7 @@ services:
82
82
 
83
83
  sidekiq:
84
84
  build: .
85
- command: bin/sidekiq
85
+ command: bunde exec sidekiq
86
86
  environment:
87
87
  - RAILS_MASTER_KEY=$RAILS_MASTER_KEY
88
88
  - REDIS_URL=redis://redis-db:6379
@@ -0,0 +1 @@
1
+ <%= fly_make_processes(fly_processes) -%>
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.0
4
+ version: 1.4.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-05-24 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -49,6 +49,7 @@ files:
49
49
  - lib/generators/templates/docker-entrypoint.erb
50
50
  - lib/generators/templates/dockerfile.yml.erb
51
51
  - lib/generators/templates/dockerignore.erb
52
+ - lib/generators/templates/fly.toml.erb
52
53
  - lib/generators/templates/litefs.yml.erb
53
54
  - lib/generators/templates/node-version.erb
54
55
  homepage: https://github.com/fly-apps/dockerfile-rails