kamal 2.0.0.beta2 → 2.0.0.rc2

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: 4ecbda147c5d6acff593f449f0ba0aa0f721bbbe56fbe2718819a55539ff5a66
4
- data.tar.gz: 5d83d711f125217fd1d0d1f1ef82807d8fe1e7a04bdb0bb73c22a2614037720b
3
+ metadata.gz: 66274957731c4a6f74e80a8eac201e287f6cace259677ec8228dded3a4b2a31a
4
+ data.tar.gz: 105026139c5e405befb49bd5452a7d340bb0f5a21189fbe2b9fca55520d29849
5
5
  SHA512:
6
- metadata.gz: '049f3a8e91a724d1d43d9cea996231b362fd0f3bb325c3488827c1d83aec07c6f50a6cf5f4206ea80632d8901438c20b731f3170be665a5026081d7417f099a1'
7
- data.tar.gz: fc061ceab3bff080b5f24f3206df556c756c9122be125eccd85591bf36a7740c957df77244af1ee72d7770ed7052895e59336d6cb5f794abb300437ba2e057b7
6
+ metadata.gz: 1bd481c2dd613bb39375cd86ec089fed42bb860dd7e48b27c6f0fa6e1a5b4700ef10cce32abb31e3af36d3c35cb87927d49e2779d5164e605de684a344239eba
7
+ data.tar.gz: 1b9aee5661c04f4fd8a4e40eab50610d4573a2dbbb3c2cc737f2d22cf962a1023f33f42b2de67b0f076cbfa117027681d1f3d16d4a0ebb9e7bcb0dbcdc1bcc1b
@@ -147,23 +147,25 @@ class Kamal::Cli::Accessory < Kamal::Cli::Base
147
147
  option :grep, aliases: "-g", desc: "Show lines with grep match only (use this to fetch specific requests by id)"
148
148
  option :grep_options, aliases: "-o", desc: "Additional options supplied to grep"
149
149
  option :follow, aliases: "-f", desc: "Follow logs on primary server (or specific host set by --hosts)"
150
+ option :skip_timestamps, type: :boolean, aliases: "-T", desc: "Skip appending timestamps to logging output"
150
151
  def logs(name)
151
152
  with_accessory(name) do |accessory, hosts|
152
153
  grep = options[:grep]
153
154
  grep_options = options[:grep_options]
155
+ timestamps = !options[:skip_timestamps]
154
156
 
155
157
  if options[:follow]
156
158
  run_locally do
157
159
  info "Following logs on #{hosts}..."
158
- info accessory.follow_logs(grep: grep, grep_options: grep_options)
159
- exec accessory.follow_logs(grep: grep, grep_options: grep_options)
160
+ info accessory.follow_logs(timestamps: timestamps, grep: grep, grep_options: grep_options)
161
+ exec accessory.follow_logs(timestamps: timestamps, grep: grep, grep_options: grep_options)
160
162
  end
161
163
  else
162
164
  since = options[:since]
163
165
  lines = options[:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set
164
166
 
165
167
  on(hosts) do
166
- puts capture_with_info(*accessory.logs(since: since, lines: lines, grep: grep, grep_options: grep_options))
168
+ puts capture_with_info(*accessory.logs(timestamps: timestamps, since: since, lines: lines, grep: grep, grep_options: grep_options))
167
169
  end
168
170
  end
169
171
  end
data/lib/kamal/cli/app.rb CHANGED
@@ -188,12 +188,14 @@ class Kamal::Cli::App < Kamal::Cli::Base
188
188
  option :grep, aliases: "-g", desc: "Show lines with grep match only (use this to fetch specific requests by id)"
189
189
  option :grep_options, aliases: "-o", desc: "Additional options supplied to grep"
190
190
  option :follow, aliases: "-f", desc: "Follow log on primary server (or specific host set by --hosts)"
191
+ option :skip_timestamps, type: :boolean, aliases: "-T", desc: "Skip appending timestamps to logging output"
191
192
  def logs
192
193
  # FIXME: Catch when app containers aren't running
193
194
 
194
195
  grep = options[:grep]
195
196
  grep_options = options[:grep_options]
196
197
  since = options[:since]
198
+ timestamps = !options[:skip_timestamps]
197
199
 
198
200
  if options[:follow]
199
201
  lines = options[:lines].presence || ((since || grep) ? nil : 10) # Default to 10 lines if since or grep isn't set
@@ -205,8 +207,8 @@ class Kamal::Cli::App < Kamal::Cli::Base
205
207
  role = KAMAL.roles_on(KAMAL.primary_host).first
206
208
 
207
209
  app = KAMAL.app(role: role, host: host)
208
- info app.follow_logs(host: KAMAL.primary_host, lines: lines, grep: grep, grep_options: grep_options)
209
- exec app.follow_logs(host: KAMAL.primary_host, lines: lines, grep: grep, grep_options: grep_options)
210
+ info app.follow_logs(host: KAMAL.primary_host, timestamps: timestamps, lines: lines, grep: grep, grep_options: grep_options)
211
+ exec app.follow_logs(host: KAMAL.primary_host, timestamps: timestamps, lines: lines, grep: grep, grep_options: grep_options)
210
212
  end
211
213
  else
212
214
  lines = options[:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set
@@ -216,7 +218,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
216
218
 
217
219
  roles.each do |role|
218
220
  begin
219
- puts_by_host host, capture_with_info(*KAMAL.app(role: role, host: host).logs(since: since, lines: lines, grep: grep, grep_options: grep_options))
221
+ puts_by_host host, capture_with_info(*KAMAL.app(role: role, host: host).logs(timestamps: timestamps, since: since, lines: lines, grep: grep, grep_options: grep_options))
220
222
  rescue SSHKit::Command::Failed
221
223
  puts_by_host host, "Nothing found"
222
224
  end
@@ -140,21 +140,23 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
140
140
  option :lines, type: :numeric, aliases: "-n", desc: "Number of log lines to pull from each server"
141
141
  option :grep, aliases: "-g", desc: "Show lines with grep match only (use this to fetch specific requests by id)"
142
142
  option :follow, aliases: "-f", desc: "Follow logs on primary server (or specific host set by --hosts)"
143
+ option :skip_timestamps, type: :boolean, aliases: "-T", desc: "Skip appending timestamps to logging output"
143
144
  def logs
144
145
  grep = options[:grep]
146
+ timestamps = !options[:skip_timestamps]
145
147
 
146
148
  if options[:follow]
147
149
  run_locally do
148
150
  info "Following logs on #{KAMAL.primary_host}..."
149
- info KAMAL.proxy.follow_logs(host: KAMAL.primary_host, grep: grep)
150
- exec KAMAL.proxy.follow_logs(host: KAMAL.primary_host, grep: grep)
151
+ info KAMAL.proxy.follow_logs(host: KAMAL.primary_host, timestamps: timestamps, grep: grep)
152
+ exec KAMAL.proxy.follow_logs(host: KAMAL.primary_host, timestamps: timestamps, grep: grep)
151
153
  end
152
154
  else
153
155
  since = options[:since]
154
156
  lines = options[:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set
155
157
 
156
158
  on(KAMAL.proxy_hosts) do |host|
157
- puts_by_host host, capture(*KAMAL.proxy.logs(since: since, lines: lines, grep: grep)), type: "Proxy"
159
+ puts_by_host host, capture(*KAMAL.proxy.logs(timestamps: timestamps, since: since, lines: lines, grep: grep)), type: "Proxy"
158
160
  end
159
161
  end
160
162
  end
@@ -39,16 +39,16 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
39
39
  end
40
40
 
41
41
 
42
- def logs(since: nil, lines: nil, grep: nil, grep_options: nil)
42
+ def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
43
43
  pipe \
44
- docker(:logs, service_name, (" --since #{since}" if since), (" --tail #{lines}" if lines), "--timestamps", "2>&1"),
44
+ docker(:logs, service_name, (" --since #{since}" if since), (" --tail #{lines}" if lines), ("--timestamps" if timestamps), "2>&1"),
45
45
  ("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
46
46
  end
47
47
 
48
- def follow_logs(grep: nil, grep_options: nil)
48
+ def follow_logs(timestamps: true, grep: nil, grep_options: nil)
49
49
  run_over_ssh \
50
50
  pipe \
51
- docker(:logs, service_name, "--timestamps", "--tail", "10", "--follow", "2>&1"),
51
+ docker(:logs, service_name, ("--timestamps" if timestamps), "--tail", "10", "--follow", "2>&1"),
52
52
  (%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
53
53
  end
54
54
 
@@ -1,16 +1,16 @@
1
1
  module Kamal::Commands::App::Logging
2
- def logs(version: nil, since: nil, lines: nil, grep: nil, grep_options: nil)
2
+ def logs(version: nil, timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
3
3
  pipe \
4
4
  version ? container_id_for_version(version) : current_running_container_id,
5
- "xargs docker logs#{" --since #{since}" if since}#{" --tail #{lines}" if lines} 2>&1",
5
+ "xargs docker logs#{" --timestamps" if timestamps}#{" --since #{since}" if since}#{" --tail #{lines}" if lines} 2>&1",
6
6
  ("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
7
7
  end
8
8
 
9
- def follow_logs(host:, lines: nil, grep: nil, grep_options: nil)
9
+ def follow_logs(host:, timestamps: true, lines: nil, grep: nil, grep_options: nil)
10
10
  run_over_ssh \
11
11
  pipe(
12
12
  current_running_container_id,
13
- "xargs docker logs --timestamps#{" --tail #{lines}" if lines} --follow 2>&1",
13
+ "xargs docker logs#{" --timestamps" if timestamps}#{" --tail #{lines}" if lines} --follow 2>&1",
14
14
  (%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
15
15
  ),
16
16
  host: host
@@ -35,15 +35,15 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base
35
35
  [ :cut, "-d:", "-f2" ]
36
36
  end
37
37
 
38
- def logs(since: nil, lines: nil, grep: nil, grep_options: nil)
38
+ def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
39
39
  pipe \
40
- docker(:logs, container_name, (" --since #{since}" if since), (" --tail #{lines}" if lines), "--timestamps", "2>&1"),
40
+ docker(:logs, container_name, ("--since #{since}" if since), ("--tail #{lines}" if lines), ("--timestamps" if timestamps), "2>&1"),
41
41
  ("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
42
42
  end
43
43
 
44
- def follow_logs(host:, grep: nil, grep_options: nil)
44
+ def follow_logs(host:, timestamps: true, grep: nil, grep_options: nil)
45
45
  run_over_ssh pipe(
46
- docker(:logs, container_name, "--timestamps", "--tail", "10", "--follow", "2>&1"),
46
+ docker(:logs, container_name, ("--timestamps" if timestamps), "--tail", "10", "--follow", "2>&1"),
47
47
  (%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
48
48
  ).join(" "), host: host
49
49
  end
@@ -2,10 +2,6 @@
2
2
  #
3
3
  # The builder configuration controls how the application is built with `docker build`
4
4
  #
5
- # If no configuration is specified, Kamal will:
6
- # 1. Create a buildx context called `kamal-local-docker-container`, using the docker-container driver
7
- # 2. Use `docker build` to build a multiarch image for linux/amd64,linux/arm64 with that context
8
- #
9
5
  # See https://kamal-deploy.org/docs/configuration/builder-examples/ for more information
10
6
 
11
7
  # Builder options
@@ -78,7 +74,7 @@ builder:
78
74
 
79
75
  # Build secrets
80
76
  #
81
- # Values are read from the .kamal/secrets.
77
+ # Values are read from .kamal/secrets.
82
78
  #
83
79
  secrets:
84
80
  - SECRET1
@@ -36,6 +36,8 @@ image: my-image
36
36
  labels:
37
37
  my-label: my-value
38
38
 
39
+ # Volumes
40
+ #
39
41
  # Additional volumes to mount into the container
40
42
  volumes:
41
43
  - /path/on/host:/path/in/container:ro
@@ -58,7 +60,7 @@ servers:
58
60
  env:
59
61
  ...
60
62
 
61
- # Asset Bridging
63
+ # Asset Path
62
64
  #
63
65
  # Used for asset bridging across deployments, default to `nil`
64
66
  #
@@ -74,6 +76,8 @@ env:
74
76
  # To configure this, set the path to the assets:
75
77
  asset_path: /path/to/assets
76
78
 
79
+ # Hooks path
80
+ #
77
81
  # Path to hooks, defaults to `.kamal/hooks`
78
82
  # See https://kamal-deploy.org/docs/hooks for more information
79
83
  hooks_path: /user_home/kamal/hooks
@@ -83,7 +87,7 @@ hooks_path: /user_home/kamal/hooks
83
87
  # Whether deployments require a destination to be specified, defaults to `false`
84
88
  require_destination: true
85
89
 
86
- # The primary role
90
+ # Primary role
87
91
  #
88
92
  # This defaults to `web`, but if you have no web role, you can change this
89
93
  primary_role: workers
@@ -12,11 +12,16 @@ env:
12
12
  DATABASE_HOST: mysql-db1
13
13
  DATABASE_PORT: 3306
14
14
 
15
- # Using .kamal/secrets file to load required environment variables
15
+ # Secrets
16
16
  #
17
- # Kamal uses dotenv to automatically load environment variables set in the .kamal/secrets file.
17
+ # Kamal uses dotenv to automatically load environment variables set in the `.kamal/secrets` file.
18
18
  #
19
- # This file can be used to set variables like KAMAL_REGISTRY_PASSWORD or database passwords.
19
+ # If you are using destinations, secrets will instead be read from `.kamal/secrets-<DESTINATION>` if
20
+ # it exists.
21
+ #
22
+ # Common secrets across all destinations can be set in `.kamal/secrets-common`.
23
+ #
24
+ # This file can be used to set variables like `KAMAL_REGISTRY_PASSWORD` or database passwords.
20
25
  # You can use variable or command substitution in the secrets file.
21
26
  #
22
27
  # ```
@@ -24,6 +29,14 @@ env:
24
29
  # RAILS_MASTER_KEY=$(cat config/master.key)
25
30
  # ```
26
31
  #
32
+ # You can also use [secret helpers](../commands/secrets) for some common password managers.
33
+ # ```
34
+ # SECRETS=$(kamal secrets fetch ...)
35
+ #
36
+ # REGISTRY_PASSWORD=$(kamal secrets extract REGISTRY_PASSWORD $SECRETS)
37
+ # DB_PASSWORD=$(kamal secrets extract DB_PASSWORD $SECRETS)
38
+ # ```
39
+ #
27
40
  # If you store secrets directly in .kamal/secrets, ensure that it is not checked into version control.
28
41
  #
29
42
  # To pass the secrets you should list them under the `secret` key. When you do this the
@@ -47,7 +47,7 @@ proxy:
47
47
  # Response timeout
48
48
  #
49
49
  # How long to wait for requests to complete before timing out, defaults to 30 seconds
50
- response_timeout: 10s
50
+ response_timeout: 10
51
51
 
52
52
  # Healthcheck
53
53
  #
@@ -91,7 +91,7 @@ proxy:
91
91
 
92
92
  # Forward headers
93
93
  #
94
- # Whether to forward the X-Forwarded-For and X-Forwarded-Proto headers (defaults to false)
94
+ # Whether to forward the X-Forwarded-For and X-Forwarded-Proto headers.
95
95
  #
96
96
  # If you are behind a trusted proxy, you can set this to true to forward the headers.
97
97
  #
@@ -26,8 +26,12 @@ servers:
26
26
  #
27
27
  # When there are other options to set, the list of hosts goes under the `hosts` key
28
28
  #
29
- # By default only the primary role uses a proxy, but you can set `proxy` to change
30
- # it.
29
+ # By default only the primary role uses a proxy.
30
+ #
31
+ # For other roles, you can set it to `proxy: true` enable it and inherit the root proxy
32
+ # configuration or provide a map of options to override the root configuration.
33
+ #
34
+ # For the primary role, you can set `proxy: false` to disable the proxy.
31
35
  #
32
36
  # You can also set a custom cmd to run in the container, and overwrite other settings
33
37
  # from the root configuration.
data/lib/kamal/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kamal
2
- VERSION = "2.0.0.beta2"
2
+ VERSION = "2.0.0.rc2"
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.beta2
4
+ version: 2.0.0.rc2
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-19 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport