kamal 2.0.0.beta1 → 2.0.0.beta2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c08e90e760f2392afcd73847fa1d9f7e987c684d687f49f227b808fda6cc28d5
4
- data.tar.gz: c0945022760eeca770901d2c163c58a4a46a11f917e29f2d516d95d4af51ef3c
3
+ metadata.gz: 4ecbda147c5d6acff593f449f0ba0aa0f721bbbe56fbe2718819a55539ff5a66
4
+ data.tar.gz: 5d83d711f125217fd1d0d1f1ef82807d8fe1e7a04bdb0bb73c22a2614037720b
5
5
  SHA512:
6
- metadata.gz: 80ee86cd4b2ee5f5369cb6b1a7b81165a313cdedfd11352eb9215c5b6bf792be627927fad72c3bf25f69d12bcbf02a1fd088771ac495b45c0272145f16536f3f
7
- data.tar.gz: df01ab908c65534003c0f089727c5ec6165be5ad72e72fab0f71c73c181ba0c8d7230a1887a2a3d7650c1f0ecfe2db349ebc2367ed64fbf052863d3bf37e4b57
6
+ metadata.gz: '049f3a8e91a724d1d43d9cea996231b362fd0f3bb325c3488827c1d83aec07c6f50a6cf5f4206ea80632d8901438c20b731f3170be665a5026081d7417f099a1'
7
+ data.tar.gz: fc061ceab3bff080b5f24f3206df556c756c9122be125eccd85591bf36a7740c957df77244af1ee72d7770ed7052895e59336d6cb5f794abb300437ba2e057b7
@@ -135,8 +135,10 @@ module Kamal::Cli
135
135
  details = { hosts: KAMAL.hosts.join(","), command: command, subcommand: subcommand }
136
136
 
137
137
  say "Running the #{hook} hook...", :magenta
138
- run_locally do
139
- execute *KAMAL.hook.run(hook, **details, **extra_details)
138
+ with_env KAMAL.hook.env(**details, **extra_details) do
139
+ run_locally do
140
+ execute *KAMAL.hook.run(hook)
141
+ end
140
142
  rescue SSHKit::Command::Failed => e
141
143
  raise HookError.new("Hook `#{hook}` failed:\n#{e.message}")
142
144
  end
@@ -183,5 +185,14 @@ module Kamal::Cli
183
185
  execute(*KAMAL.server.ensure_run_directory)
184
186
  end
185
187
  end
188
+
189
+ def with_env(env)
190
+ current_env = ENV.to_h.dup
191
+ ENV.update(env)
192
+ yield
193
+ ensure
194
+ ENV.clear
195
+ ENV.update(current_env)
196
+ end
186
197
  end
187
198
  end
@@ -30,28 +30,30 @@ class Kamal::Cli::Build < Kamal::Cli::Base
30
30
  say "Building with uncommitted changes:\n #{uncommitted_changes}", :yellow
31
31
  end
32
32
 
33
- run_locally do
34
- begin
35
- execute *KAMAL.builder.inspect_builder
36
- rescue SSHKit::Command::Failed => e
37
- if e.message =~ /(context not found|no builder|no compatible builder|does not exist)/
38
- warn "Missing compatible builder, so creating a new one first"
39
- begin
40
- cli.remove
41
- rescue SSHKit::Command::Failed
42
- raise unless e.message =~ /(context not found|no builder|does not exist)/
33
+ with_env(KAMAL.config.builder.secrets) do
34
+ run_locally do
35
+ begin
36
+ execute *KAMAL.builder.inspect_builder
37
+ rescue SSHKit::Command::Failed => e
38
+ if e.message =~ /(context not found|no builder|no compatible builder|does not exist)/
39
+ warn "Missing compatible builder, so creating a new one first"
40
+ begin
41
+ cli.remove
42
+ rescue SSHKit::Command::Failed
43
+ raise unless e.message =~ /(context not found|no builder|does not exist)/
44
+ end
45
+ cli.create
46
+ else
47
+ raise
43
48
  end
44
- cli.create
45
- else
46
- raise
47
49
  end
48
- end
49
50
 
50
- # Get the command here to ensure the Dir.chdir doesn't interfere with it
51
- push = KAMAL.builder.push
51
+ # Get the command here to ensure the Dir.chdir doesn't interfere with it
52
+ push = KAMAL.builder.push
52
53
 
53
- KAMAL.with_verbosity(:debug) do
54
- Dir.chdir(KAMAL.config.builder.build_directory) { execute *push, env: KAMAL.config.builder.secrets }
54
+ KAMAL.with_verbosity(:debug) do
55
+ Dir.chdir(KAMAL.config.builder.build_directory) { execute *push }
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -48,7 +48,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
48
48
  end
49
49
  end
50
50
 
51
- run_hook "post-deploy", secrets: true, runtime: runtime.round
51
+ run_hook "post-deploy", secrets: true, runtime: runtime.round.to_s
52
52
  end
53
53
 
54
54
  desc "redeploy", "Deploy app to servers without bootstrapping servers, starting kamal-proxy, pruning, and registry login"
@@ -75,7 +75,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
75
75
  end
76
76
  end
77
77
 
78
- run_hook "post-deploy", secrets: true, runtime: runtime.round
78
+ run_hook "post-deploy", secrets: true, runtime: runtime.round.to_s
79
79
  end
80
80
 
81
81
  desc "rollback [VERSION]", "Rollback app to VERSION"
@@ -99,7 +99,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
99
99
  end
100
100
  end
101
101
 
102
- run_hook "post-deploy", secrets: true, runtime: runtime.round if rolled_back
102
+ run_hook "post-deploy", secrets: true, runtime: runtime.round.to_s if rolled_back
103
103
  end
104
104
 
105
105
  desc "details", "Show details about all containers"
@@ -167,7 +167,6 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
167
167
  stop
168
168
  remove_container
169
169
  remove_image
170
- remove_host_directory
171
170
  end
172
171
  end
173
172
  end
@@ -192,16 +191,6 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
192
191
  end
193
192
  end
194
193
 
195
- desc "remove_host_directory", "Remove proxy directory from servers", hide: true
196
- def remove_host_directory
197
- with_lock do
198
- on(KAMAL.proxy_hosts) do
199
- execute *KAMAL.auditor.record("Removed #{KAMAL.config.proxy_directory}"), verbosity: :debug
200
- execute *KAMAL.proxy.remove_host_directory, raise_on_non_zero_exit: false
201
- end
202
- end
203
- end
204
-
205
194
  private
206
195
  def removal_allowed?(force)
207
196
  on(KAMAL.proxy_hosts) do |host|
@@ -11,6 +11,7 @@ module Kamal::Commands::App::Execution
11
11
  docker :run,
12
12
  ("-it" if interactive),
13
13
  "--rm",
14
+ "--network", "kamal",
14
15
  *role&.env_args(host),
15
16
  *argumentize("--env", env),
16
17
  *config.volume_args,
@@ -1,9 +1,12 @@
1
1
  class Kamal::Commands::Hook < Kamal::Commands::Base
2
- def run(hook, secrets: false, **details)
3
- env = tags(**details).env
4
- env.merge!(config.secrets.to_h) if secrets
2
+ def run(hook)
3
+ [ hook_file(hook) ]
4
+ end
5
5
 
6
- [ hook_file(hook), env: env ]
6
+ def env(secrets: false, **details)
7
+ tags(**details).env.tap do |env|
8
+ env.merge!(config.secrets.to_h) if secrets
9
+ end
7
10
  end
8
11
 
9
12
  def hook_exists?(hook)
@@ -8,8 +8,7 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
8
8
  "--detach",
9
9
  "--restart", "unless-stopped",
10
10
  *config.proxy_publish_args,
11
- "--volume", "/var/run/docker.sock:/var/run/docker.sock",
12
- *config.proxy_config_volume.docker_args,
11
+ "--volume", "kamal-proxy-config:/home/kamal-proxy/.config/kamal-proxy",
13
12
  *config.logging_args,
14
13
  config.proxy_image
15
14
  end
@@ -57,10 +56,6 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
57
56
  docker :image, :prune, "--all", "--force", "--filter", "label=org.opencontainers.image.title=kamal-proxy"
58
57
  end
59
58
 
60
- def remove_host_directory
61
- remove_directory config.proxy_directory
62
- end
63
-
64
59
  def cleanup_traefik
65
60
  chain \
66
61
  docker(:container, :stop, "traefik"),
@@ -14,7 +14,7 @@ class Kamal::Configuration
14
14
 
15
15
  include Validation
16
16
 
17
- PROXY_MINIMUM_VERSION = "v0.3.0"
17
+ PROXY_MINIMUM_VERSION = "v0.4.0"
18
18
  PROXY_HTTP_PORT = 80
19
19
  PROXY_HTTPS_PORT = 443
20
20
 
@@ -216,10 +216,6 @@ class Kamal::Configuration
216
216
  File.join apps_directory, [ service, destination ].compact.join("-")
217
217
  end
218
218
 
219
- def proxy_directory
220
- File.join run_directory, "proxy"
221
- end
222
-
223
219
  def env_directory
224
220
  File.join app_directory, "env"
225
221
  end
@@ -262,12 +258,6 @@ class Kamal::Configuration
262
258
  "kamal-proxy"
263
259
  end
264
260
 
265
- def proxy_config_volume
266
- Kamal::Configuration::Volume.new \
267
- host_path: File.join(proxy_directory, "config"),
268
- container_path: "/home/kamal-proxy/.config/kamal-proxy"
269
- end
270
-
271
261
 
272
262
  def to_h
273
263
  {
data/lib/kamal/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kamal
2
- VERSION = "2.0.0.beta1"
2
+ VERSION = "2.0.0.beta2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-18 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport