kamal 1.8.3 → 2.7.0

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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/kamal/cli/accessory.rb +92 -38
  4. data/lib/kamal/cli/alias/command.rb +10 -0
  5. data/lib/kamal/cli/app/{prepare_assets.rb → assets.rb} +1 -1
  6. data/lib/kamal/cli/app/boot.rb +23 -16
  7. data/lib/kamal/cli/app/error_pages.rb +33 -0
  8. data/lib/kamal/cli/app/ssl_certificates.rb +28 -0
  9. data/lib/kamal/cli/app.rb +132 -30
  10. data/lib/kamal/cli/base.rb +57 -53
  11. data/lib/kamal/cli/build.rb +81 -38
  12. data/lib/kamal/cli/healthcheck/barrier.rb +2 -0
  13. data/lib/kamal/cli/healthcheck/poller.rb +18 -39
  14. data/lib/kamal/cli/lock.rb +2 -3
  15. data/lib/kamal/cli/main.rb +60 -59
  16. data/lib/kamal/cli/proxy.rb +290 -0
  17. data/lib/kamal/cli/prune.rb +0 -1
  18. data/lib/kamal/cli/registry.rb +2 -0
  19. data/lib/kamal/cli/secrets.rb +49 -0
  20. data/lib/kamal/cli/server.rb +6 -5
  21. data/lib/kamal/cli/templates/deploy.yml +53 -53
  22. data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +2 -12
  23. data/lib/kamal/cli/templates/sample_hooks/post-app-boot.sample +3 -0
  24. data/lib/kamal/cli/templates/sample_hooks/post-deploy.sample +1 -1
  25. data/lib/kamal/cli/templates/sample_hooks/post-proxy-reboot.sample +3 -0
  26. data/lib/kamal/cli/templates/sample_hooks/pre-app-boot.sample +3 -0
  27. data/lib/kamal/cli/templates/sample_hooks/pre-build.sample +1 -1
  28. data/lib/kamal/cli/templates/sample_hooks/pre-connect.sample +1 -1
  29. data/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample +19 -6
  30. data/lib/kamal/cli/templates/sample_hooks/pre-proxy-reboot.sample +3 -0
  31. data/lib/kamal/cli/templates/secrets +17 -0
  32. data/lib/kamal/cli.rb +2 -0
  33. data/lib/kamal/commander/specifics.rb +19 -6
  34. data/lib/kamal/commander.rb +39 -32
  35. data/lib/kamal/commands/accessory/proxy.rb +16 -0
  36. data/lib/kamal/commands/accessory.rb +19 -19
  37. data/lib/kamal/commands/app/assets.rb +10 -10
  38. data/lib/kamal/commands/app/containers.rb +2 -2
  39. data/lib/kamal/commands/app/error_pages.rb +9 -0
  40. data/lib/kamal/commands/app/execution.rb +7 -4
  41. data/lib/kamal/commands/app/images.rb +1 -1
  42. data/lib/kamal/commands/app/logging.rb +16 -6
  43. data/lib/kamal/commands/app/proxy.rb +32 -0
  44. data/lib/kamal/commands/app.rb +25 -24
  45. data/lib/kamal/commands/auditor.rb +12 -3
  46. data/lib/kamal/commands/base.rb +54 -8
  47. data/lib/kamal/commands/builder/base.rb +46 -16
  48. data/lib/kamal/commands/builder/clone.rb +16 -14
  49. data/lib/kamal/commands/builder/cloud.rb +22 -0
  50. data/lib/kamal/commands/builder/hybrid.rb +21 -0
  51. data/lib/kamal/commands/builder/local.rb +14 -0
  52. data/lib/kamal/commands/builder/pack.rb +46 -0
  53. data/lib/kamal/commands/builder/remote.rb +63 -0
  54. data/lib/kamal/commands/builder.rb +21 -45
  55. data/lib/kamal/commands/docker.rb +4 -0
  56. data/lib/kamal/commands/hook.rb +8 -2
  57. data/lib/kamal/commands/lock.rb +2 -6
  58. data/lib/kamal/commands/proxy.rb +127 -0
  59. data/lib/kamal/commands/prune.rb +1 -9
  60. data/lib/kamal/commands/registry.rb +9 -7
  61. data/lib/kamal/commands/server.rb +11 -1
  62. data/lib/kamal/configuration/accessory.rb +89 -12
  63. data/lib/kamal/configuration/alias.rb +15 -0
  64. data/lib/kamal/configuration/builder.rb +73 -15
  65. data/lib/kamal/configuration/docs/accessory.yml +53 -15
  66. data/lib/kamal/configuration/docs/alias.yml +26 -0
  67. data/lib/kamal/configuration/docs/boot.yml +3 -3
  68. data/lib/kamal/configuration/docs/builder.yml +63 -38
  69. data/lib/kamal/configuration/docs/configuration.yml +62 -46
  70. data/lib/kamal/configuration/docs/env.yml +61 -17
  71. data/lib/kamal/configuration/docs/logging.yml +3 -3
  72. data/lib/kamal/configuration/docs/proxy.yml +168 -0
  73. data/lib/kamal/configuration/docs/registry.yml +20 -13
  74. data/lib/kamal/configuration/docs/role.yml +14 -13
  75. data/lib/kamal/configuration/docs/servers.yml +2 -2
  76. data/lib/kamal/configuration/docs/ssh.yml +23 -19
  77. data/lib/kamal/configuration/docs/sshkit.yml +4 -4
  78. data/lib/kamal/configuration/env/tag.rb +4 -3
  79. data/lib/kamal/configuration/env.rb +19 -17
  80. data/lib/kamal/configuration/proxy/boot.rb +129 -0
  81. data/lib/kamal/configuration/proxy.rb +124 -0
  82. data/lib/kamal/configuration/registry.rb +7 -6
  83. data/lib/kamal/configuration/role.rb +69 -98
  84. data/lib/kamal/configuration/servers.rb +8 -1
  85. data/lib/kamal/configuration/validator/accessory.rb +6 -2
  86. data/lib/kamal/configuration/validator/alias.rb +15 -0
  87. data/lib/kamal/configuration/validator/builder.rb +6 -0
  88. data/lib/kamal/configuration/validator/proxy.rb +25 -0
  89. data/lib/kamal/configuration/validator/role.rb +3 -1
  90. data/lib/kamal/configuration/validator/servers.rb +1 -1
  91. data/lib/kamal/configuration/validator.rb +62 -24
  92. data/lib/kamal/configuration.rb +96 -50
  93. data/lib/kamal/docker.rb +30 -0
  94. data/lib/kamal/env_file.rb +7 -1
  95. data/lib/kamal/git.rb +10 -0
  96. data/lib/kamal/secrets/adapters/aws_secrets_manager.rb +51 -0
  97. data/lib/kamal/secrets/adapters/base.rb +33 -0
  98. data/lib/kamal/secrets/adapters/bitwarden.rb +81 -0
  99. data/lib/kamal/secrets/adapters/bitwarden_secrets_manager.rb +66 -0
  100. data/lib/kamal/secrets/adapters/doppler.rb +57 -0
  101. data/lib/kamal/secrets/adapters/enpass.rb +71 -0
  102. data/lib/kamal/secrets/adapters/gcp_secret_manager.rb +112 -0
  103. data/lib/kamal/secrets/adapters/last_pass.rb +40 -0
  104. data/lib/kamal/secrets/adapters/one_password.rb +104 -0
  105. data/lib/kamal/secrets/adapters/passbolt.rb +130 -0
  106. data/lib/kamal/secrets/adapters/test.rb +14 -0
  107. data/lib/kamal/secrets/adapters.rb +16 -0
  108. data/lib/kamal/secrets/dotenv/inline_command_substitution.rb +33 -0
  109. data/lib/kamal/secrets.rb +42 -0
  110. data/lib/kamal/sshkit_with_ext.rb +1 -0
  111. data/lib/kamal/utils.rb +30 -0
  112. data/lib/kamal/version.rb +1 -1
  113. data/lib/kamal.rb +3 -1
  114. metadata +63 -36
  115. data/lib/kamal/cli/env.rb +0 -54
  116. data/lib/kamal/cli/templates/sample_hooks/post-traefik-reboot.sample +0 -3
  117. data/lib/kamal/cli/templates/sample_hooks/pre-traefik-reboot.sample +0 -3
  118. data/lib/kamal/cli/templates/template.env +0 -2
  119. data/lib/kamal/cli/traefik.rb +0 -122
  120. data/lib/kamal/commands/app/cord.rb +0 -22
  121. data/lib/kamal/commands/builder/multiarch/remote.rb +0 -65
  122. data/lib/kamal/commands/builder/multiarch.rb +0 -41
  123. data/lib/kamal/commands/builder/native/cached.rb +0 -25
  124. data/lib/kamal/commands/builder/native/remote.rb +0 -67
  125. data/lib/kamal/commands/builder/native.rb +0 -20
  126. data/lib/kamal/commands/traefik.rb +0 -85
  127. data/lib/kamal/configuration/docs/healthcheck.yml +0 -59
  128. data/lib/kamal/configuration/docs/traefik.yml +0 -62
  129. data/lib/kamal/configuration/healthcheck.rb +0 -63
  130. data/lib/kamal/configuration/traefik.rb +0 -60
@@ -1,47 +1,54 @@
1
1
  # Builder
2
2
  #
3
- # The builder configuration controls how the application is built with `docker build` or `docker buildx build`
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-<service>-multiarch`
7
- # 2. Use `docker buildx build` to build a multiarch image for linux/amd64,linux/arm64 with that context
8
- #
9
- # See https://kamal-deploy.org/docs/configuration/builder-examples/ for more information
5
+ # See https://kamal-deploy.org/docs/configuration/builder-examples/ for more information.
10
6
 
11
7
  # Builder options
12
8
  #
13
9
  # Options go under the builder key in the root configuration.
14
10
  builder:
15
11
 
16
- # Multiarch
12
+ # Arch
17
13
  #
18
- # Enables multiarch builds, defaults to `true`
19
- multiarch: false
20
-
21
- # Local configuration
14
+ # The architectures to build for — you can set an array or just a single value.
22
15
  #
23
- # The build configuration for local builds, only used if multiarch is enabled (the default)
16
+ # Allowed values are `amd64` and `arm64`:
17
+ arch:
18
+ - amd64
19
+
20
+ # Remote
24
21
  #
25
- # If there is no remote configuration, by default we build for amd64 and arm64.
26
- # If you only want to build for one architecture, you can specify it here.
27
- # The docker socket is optional and uses the default docker host socket when not specified
28
- local:
29
- arch: amd64
30
- host: /var/run/docker.sock
22
+ # The connection string for a remote builder. If supplied, Kamal will use this
23
+ # for builds that do not match the local architecture of the deployment host.
24
+ remote: ssh://docker@docker-builder
31
25
 
32
- # Remote configuration
26
+ # Local
27
+ #
28
+ # If set to false, Kamal will always use the remote builder even when building
29
+ # the local architecture.
33
30
  #
34
- # The build configuration for remote builds, also only used if multiarch is enabled.
35
- # The arch is required and can be either amd64 or arm64.
36
- remote:
37
- arch: arm64
38
- host: ssh://docker@docker-builder
31
+ # Defaults to true:
32
+ local: true
33
+
34
+ # Buildpack configuration
35
+ #
36
+ # The build configuration for using pack to build a Cloud Native Buildpack image.
37
+ #
38
+ # For additional buildpack customization options you can create a project descriptor
39
+ # file(project.toml) that the Pack CLI will automatically use.
40
+ # See https://buildpacks.io/docs/for-app-developers/how-to/build-inputs/use-project-toml/ for more information.
41
+ pack:
42
+ builder: heroku/builder:24
43
+ buildpacks:
44
+ - heroku/ruby
45
+ - heroku/procfile
39
46
 
40
47
  # Builder cache
41
48
  #
42
- # The type must be either 'gha' or 'registry'
49
+ # The type must be either 'gha' or 'registry'.
43
50
  #
44
- # The image is only used for registry cache
51
+ # The image is only used for registry cache and is not compatible with the Docker driver:
45
52
  cache:
46
53
  type: registry
47
54
  options: mode=max
@@ -49,25 +56,25 @@ builder:
49
56
 
50
57
  # Build context
51
58
  #
52
- # If this is not set, then a local git clone of the repo is used.
59
+ # If this is not set, then a local Git clone of the repo is used.
53
60
  # This ensures a clean build with no uncommitted changes.
54
61
  #
55
- # To use the local checkout instead you can set the context to `.`, or a path to another directory.
62
+ # To use the local checkout instead, you can set the context to `.`, or a path to another directory.
56
63
  context: .
57
64
 
58
65
  # Dockerfile
59
66
  #
60
- # The Dockerfile to use for building, defaults to `Dockerfile`
67
+ # The Dockerfile to use for building, defaults to `Dockerfile`:
61
68
  dockerfile: Dockerfile.production
62
69
 
63
70
  # Build target
64
71
  #
65
- # If not set, then the default target is used
72
+ # If not set, then the default target is used:
66
73
  target: production
67
74
 
68
- # Build Arguments
75
+ # Build arguments
69
76
  #
70
- # Any additional build arguments, passed to `docker build` with `--build-arg <key>=<value>`
77
+ # Any additional build arguments, passed to `docker build` with `--build-arg <key>=<value>`:
71
78
  args:
72
79
  ENVIRONMENT: production
73
80
 
@@ -80,28 +87,46 @@ builder:
80
87
 
81
88
  # Build secrets
82
89
  #
83
- # Values are read from the environment.
84
- #
90
+ # Values are read from `.kamal/secrets`:
85
91
  secrets:
86
92
  - SECRET1
87
93
  - SECRET2
88
94
 
89
- # Referencing Build Secrets
95
+ # Referencing build secrets
90
96
  #
91
97
  # ```shell
92
98
  # # Copy Gemfiles
93
99
  # COPY Gemfile Gemfile.lock ./
94
100
  #
95
101
  # # Install dependencies, including private repositories via access token
96
- # # Then remove bundle cache with exposed GITHUB_TOKEN)
102
+ # # Then remove bundle cache with exposed GITHUB_TOKEN
97
103
  # RUN --mount=type=secret,id=GITHUB_TOKEN \
98
104
  # BUNDLE_GITHUB__COM=x-access-token:$(cat /run/secrets/GITHUB_TOKEN) \
99
105
  # bundle install && \
100
106
  # rm -rf /usr/local/bundle/cache
101
107
  # ```
102
108
 
103
-
104
109
  # SSH
105
110
  #
106
- # SSH agent socket or keys to expose to the build
111
+ # SSH agent socket or keys to expose to the build:
107
112
  ssh: default=$SSH_AUTH_SOCK
113
+
114
+ # Driver
115
+ #
116
+ # The build driver to use, defaults to `docker-container`:
117
+ driver: docker
118
+ #
119
+ # If you want to use Docker Build Cloud (https://www.docker.com/products/build-cloud/), you can set the driver to:
120
+ driver: cloud org-name/builder-name
121
+
122
+ # Provenance
123
+ #
124
+ # It is used to configure provenance attestations for the build result.
125
+ # The value can also be a boolean to enable or disable provenance attestations.
126
+ provenance: mode=max
127
+
128
+ # SBOM (Software Bill of Materials)
129
+ #
130
+ # It is used to configure SBOM generation for the build result.
131
+ # The value can also be a boolean to enable or disable SBOM generation.
132
+ sbom: true
@@ -1,14 +1,13 @@
1
1
  # Kamal Configuration
2
2
  #
3
- # Configuration is read from the `config/deploy.yml`
4
- #
3
+ # Configuration is read from the `config/deploy.yml`.
5
4
 
6
5
  # Destinations
7
6
  #
8
7
  # When running commands, you can specify a destination with the `-d` flag,
9
- # e.g. `kamal deploy -d staging`
8
+ # e.g., `kamal deploy -d staging`.
10
9
  #
11
- # In this case the configuration will also be read from `config/deploy.staging.yml`
10
+ # In this case, the configuration will also be read from `config/deploy.staging.yml`
12
11
  # and merged with the base configuration.
13
12
 
14
13
  # Extensions
@@ -18,10 +17,11 @@
18
17
  # However, you might want to declare a configuration block using YAML anchors
19
18
  # and aliases to avoid repetition.
20
19
  #
21
- # You can use prefix a configuration section with `x-` to indicate that it is an
20
+ # You can prefix a configuration section with `x-` to indicate that it is an
22
21
  # extension. Kamal will ignore the extension and not raise an error.
23
22
 
24
23
  # The service name
24
+ #
25
25
  # This is a required value. It is used as the container name prefix.
26
26
  service: myapp
27
27
 
@@ -32,137 +32,153 @@ image: my-image
32
32
 
33
33
  # Labels
34
34
  #
35
- # Additional labels to add to the container
35
+ # Additional labels to add to the container:
36
36
  labels:
37
37
  my-label: my-value
38
38
 
39
- # Additional volumes to mount into the container
39
+ # Volumes
40
+ #
41
+ # Additional volumes to mount into the container:
40
42
  volumes:
41
43
  - /path/on/host:/path/in/container:ro
42
44
 
43
45
  # Registry
44
46
  #
45
- # The Docker registry configuration, see kamal docs registry
47
+ # The Docker registry configuration, see kamal docs registry:
46
48
  registry:
47
49
  ...
48
50
 
49
51
  # Servers
50
52
  #
51
- # The servers to deploy to, optionally with custom roles, see kamal docs servers
53
+ # The servers to deploy to, optionally with custom roles, see kamal docs servers:
52
54
  servers:
53
55
  ...
54
56
 
55
57
  # Environment variables
56
58
  #
57
- # See kamal docs env
59
+ # See kamal docs env:
58
60
  env:
59
61
  ...
60
62
 
61
- # Asset Bridging
63
+ # Asset path
62
64
  #
63
- # Used for asset bridging across deployments, default to `nil`
65
+ # Used for asset bridging across deployments, default to `nil`.
64
66
  #
65
67
  # If there are changes to CSS or JS files, we may get requests
66
- # for the old versions on the new container and vice-versa.
68
+ # for the old versions on the new container, and vice versa.
67
69
  #
68
- # To avoid 404s we can specify an asset path.
70
+ # To avoid 404s, we can specify an asset path.
69
71
  # Kamal will replace that path in the container with a mapped
70
72
  # volume containing both sets of files.
71
73
  # This requires that file names change when the contents change
72
- # (e.g. by including a hash of the contents in the name).
73
-
74
+ # (e.g., by including a hash of the contents in the name).
75
+ #
74
76
  # To configure this, set the path to the assets:
75
77
  asset_path: /path/to/assets
76
78
 
77
- # Path to hooks, defaults to `.kamal/hooks`
78
- # See https://kamal-deploy.org/docs/hooks for more information
79
+ # Hooks path
80
+ #
81
+ # Path to hooks, defaults to `.kamal/hooks`.
82
+ # See https://kamal-deploy.org/docs/hooks for more information:
79
83
  hooks_path: /user_home/kamal/hooks
80
84
 
85
+ # Error pages
86
+ #
87
+ # A directory relative to the app root to find error pages for the proxy to serve.
88
+ # Any files in the format 4xx.html or 5xx.html will be copied to the hosts.
89
+ error_pages_path: public
90
+
81
91
  # Require destinations
82
92
  #
83
- # Whether deployments require a destination to be specified, defaults to `false`
93
+ # Whether deployments require a destination to be specified, defaults to `false`:
84
94
  require_destination: true
85
95
 
86
- # The primary role
96
+ # Primary role
87
97
  #
88
- # This defaults to `web`, but if you have no web role, you can change this
98
+ # This defaults to `web`, but if you have no web role, you can change this:
89
99
  primary_role: workers
90
100
 
91
101
  # Allowing empty roles
92
102
  #
93
- # Whether roles with no servers are allowed. Defaults to `false`.
103
+ # Whether roles with no servers are allowed. Defaults to `false`:
94
104
  allow_empty_roles: false
95
105
 
96
- # Stop wait time
97
- #
98
- # How long we wait for a container to stop before killing it, defaults to 30 seconds
99
- stop_wait_time: 60
100
-
101
106
  # Retain containers
102
107
  #
103
- # How many old containers and images we retain, defaults to 5
108
+ # How many old containers and images we retain, defaults to 5:
104
109
  retain_containers: 3
105
110
 
106
111
  # Minimum version
107
112
  #
108
- # The minimum version of Kamal required to deploy this configuration, defaults to nil
113
+ # The minimum version of Kamal required to deploy this configuration, defaults to `nil`:
109
114
  minimum_version: 1.3.0
110
115
 
111
116
  # Readiness delay
112
117
  #
113
- # Seconds to wait for a container to boot after is running, default 7
114
- # This only applies to containers that do not specify a healthcheck
118
+ # Seconds to wait for a container to boot after it is running, default 7.
119
+ #
120
+ # This only applies to containers that do not run a proxy or specify a healthcheck:
115
121
  readiness_delay: 4
116
122
 
123
+ # Deploy timeout
124
+ #
125
+ # How long to wait for a container to become ready, default 30:
126
+ deploy_timeout: 10
127
+
128
+ # Drain timeout
129
+ #
130
+ # How long to wait for a container to drain, default 30:
131
+ drain_timeout: 10
132
+
117
133
  # Run directory
118
134
  #
119
- # Directory to store kamal runtime files in on the host, default `.kamal`
135
+ # Directory to store kamal runtime files in on the host, default `.kamal`:
120
136
  run_directory: /etc/kamal
121
137
 
122
138
  # SSH options
123
139
  #
124
- # See kamal docs ssh
140
+ # See kamal docs ssh:
125
141
  ssh:
126
142
  ...
127
143
 
128
144
  # Builder options
129
145
  #
130
- # See kamal docs builder
146
+ # See kamal docs builder:
131
147
  builder:
132
148
  ...
133
149
 
134
150
  # Accessories
135
151
  #
136
- # Additionals services to run in Docker, see kamal docs accessory
152
+ # Additional services to run in Docker, see kamal docs accessory:
137
153
  accessories:
138
154
  ...
139
155
 
140
- # Traefik
156
+ # Proxy
141
157
  #
142
- # The Traefik proxy is used for zero-downtime deployments, see kamal docs traefik
143
- traefik:
158
+ # Configuration for kamal-proxy, see kamal docs proxy:
159
+ proxy:
144
160
  ...
145
161
 
146
162
  # SSHKit
147
163
  #
148
- # See kamal docs sshkit
164
+ # See kamal docs sshkit:
149
165
  sshkit:
150
166
  ...
151
167
 
152
168
  # Boot options
153
169
  #
154
- # See kamal docs boot
170
+ # See kamal docs boot:
155
171
  boot:
156
172
  ...
157
173
 
158
- # Healthcheck
174
+ # Logging
159
175
  #
160
- # Configuring healthcheck commands, intervals and timeouts, see kamal docs healthcheck
161
- healthcheck:
176
+ # Docker logging configuration, see kamal docs logging:
177
+ logging:
162
178
  ...
163
179
 
164
- # Logging
180
+ # Aliases
165
181
  #
166
- # Docker logging configuration, see kamal docs logging
167
- logging:
182
+ # Alias configuration, see kamal docs alias:
183
+ aliases:
168
184
  ...
@@ -1,49 +1,93 @@
1
1
  # Environment variables
2
2
  #
3
- # Environment variables can be set directory in the Kamal configuration or
4
- # for loaded from a .env file, for secrets that should not be checked into Git.
3
+ # Environment variables can be set directly in the Kamal configuration or
4
+ # read from `.kamal/secrets`.
5
5
 
6
6
  # Reading environment variables from the configuration
7
7
  #
8
8
  # Environment variables can be set directly in the configuration file.
9
9
  #
10
- # These are passed to the docker run command when deploying.
10
+ # These are passed to the `docker run` command when deploying.
11
11
  env:
12
12
  DATABASE_HOST: mysql-db1
13
13
  DATABASE_PORT: 3306
14
14
 
15
- # Using .env file to load required environment variables
15
+ # Secrets
16
16
  #
17
- # Kamal uses dotenv to automatically load environment variables set in the .env file present
18
- # in the application root.
17
+ # Kamal uses dotenv to automatically load environment variables set in the `.kamal/secrets` file.
19
18
  #
20
- # This file can be used to set variables like KAMAL_REGISTRY_PASSWORD or database passwords.
21
- # But for this reason you must ensure that .env files are not checked into Git or included
22
- # in your Dockerfile! The format is just key-value like:
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.
25
+ # You can use variable or command substitution in the secrets file.
26
+ #
27
+ # ```shell
28
+ # KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
29
+ # RAILS_MASTER_KEY=$(cat config/master.key)
23
30
  # ```
24
- # KAMAL_REGISTRY_PASSWORD=pw
25
- # DB_PASSWORD=secret123
31
+ #
32
+ # You can also use [secret helpers](../../commands/secrets) for some common password managers.
33
+ #
34
+ # ```shell
35
+ # SECRETS=$(kamal secrets fetch ...)
36
+ #
37
+ # REGISTRY_PASSWORD=$(kamal secrets extract REGISTRY_PASSWORD $SECRETS)
38
+ # DB_PASSWORD=$(kamal secrets extract DB_PASSWORD $SECRETS)
26
39
  # ```
27
- # See https://kamal-deploy.org/docs/commands/envify/ for how to use generated .env files.
28
40
  #
29
- # To pass the secrets you should list them under the `secret` key. When you do this the
41
+ # If you store secrets directly in `.kamal/secrets`, ensure that it is not checked into version control.
42
+ #
43
+ # To pass the secrets, you should list them under the `secret` key. When you do this, the
30
44
  # other variables need to be moved under the `clear` key.
31
45
  #
32
- # Unlike clear values, secrets are not passed directly to the container,
33
- # but are stored in an env file on the host
34
- # The file is not updated when deploying, only when running `kamal envify` or `kamal env push`.
46
+ # Unlike clear values, secrets are not passed directly to the container
47
+ # but are stored in an env file on the host:
35
48
  env:
36
49
  clear:
37
50
  DB_USER: app
38
51
  secret:
39
52
  - DB_PASSWORD
40
53
 
54
+ # Aliased secrets
55
+ #
56
+ # You can also alias secrets to other secrets using a `:` separator.
57
+ #
58
+ # This is useful when the ENV name is different from the secret name. For example, if you have two
59
+ # places where you need to define the ENV variable `DB_PASSWORD`, but the value is different depending
60
+ # on the context.
61
+ #
62
+ # ```shell
63
+ # SECRETS=$(kamal secrets fetch ...)
64
+ #
65
+ # MAIN_DB_PASSWORD=$(kamal secrets extract MAIN_DB_PASSWORD $SECRETS)
66
+ # SECONDARY_DB_PASSWORD=$(kamal secrets extract SECONDARY_DB_PASSWORD $SECRETS)
67
+ # ```
68
+ env:
69
+ secret:
70
+ - DB_PASSWORD:MAIN_DB_PASSWORD
71
+ tags:
72
+ secondary_db:
73
+ secret:
74
+ - DB_PASSWORD:SECONDARY_DB_PASSWORD
75
+ accessories:
76
+ main_db_accessory:
77
+ env:
78
+ secret:
79
+ - DB_PASSWORD:MAIN_DB_PASSWORD
80
+ secondary_db_accessory:
81
+ env:
82
+ secret:
83
+ - DB_PASSWORD:SECONDARY_DB_PASSWORD
84
+
41
85
  # Tags
42
86
  #
43
87
  # Tags are used to add extra env variables to specific hosts.
44
88
  # See kamal docs servers for how to tag hosts.
45
89
  #
46
- # Tags are only allowed in the top level env configuration (i.e not under a role specific env).
90
+ # Tags are only allowed in the top-level env configuration (i.e., not under a role-specific env).
47
91
  #
48
92
  # The env variables can be specified with secret and clear values as explained above.
49
93
  env:
@@ -6,16 +6,16 @@
6
6
  #
7
7
  # These go under the logging key in the configuration file.
8
8
  #
9
- # This can be specified in the root level or for a specific role.
9
+ # This can be specified at the root level or for a specific role.
10
10
  logging:
11
11
 
12
12
  # Driver
13
13
  #
14
- # The logging driver to use, passed to Docker via `--log-driver`
14
+ # The logging driver to use, passed to Docker via `--log-driver`:
15
15
  driver: json-file
16
16
 
17
17
  # Options
18
18
  #
19
- # Any logging options to pass to the driver, passed to Docker via `--log-opt`
19
+ # Any logging options to pass to the driver, passed to Docker via `--log-opt`:
20
20
  options:
21
21
  max-size: 100m
@@ -0,0 +1,168 @@
1
+ # Proxy
2
+ #
3
+ # Kamal uses [kamal-proxy](https://github.com/basecamp/kamal-proxy) to provide
4
+ # gapless deployments. It runs on ports 80 and 443 and forwards requests to the
5
+ # application container.
6
+ #
7
+ # The proxy is configured in the root configuration under `proxy`. These are
8
+ # options that are set when deploying the application, not when booting the proxy.
9
+ #
10
+ # They are application-specific, so they are not shared when multiple applications
11
+ # run on the same proxy.
12
+ #
13
+ proxy:
14
+
15
+ # Hosts
16
+ #
17
+ # The hosts that will be used to serve the app. The proxy will only route requests
18
+ # to this host to your app.
19
+ #
20
+ # If no hosts are set, then all requests will be forwarded, except for matching
21
+ # requests for other apps deployed on that server that do have a host set.
22
+ #
23
+ # Specify one of `host` or `hosts`.
24
+ host: foo.example.com
25
+ hosts:
26
+ - foo.example.com
27
+ - bar.example.com
28
+
29
+ # App port
30
+ #
31
+ # The port the application container is exposed on.
32
+ #
33
+ # Defaults to 80:
34
+ app_port: 3000
35
+
36
+ # SSL
37
+ #
38
+ # kamal-proxy can provide automatic HTTPS for your application via Let's Encrypt.
39
+ #
40
+ # This requires that we are deploying to one server and the host option is set.
41
+ # The host value must point to the server we are deploying to, and port 443 must be
42
+ # open for the Let's Encrypt challenge to succeed.
43
+ #
44
+ # If you set `ssl` to `true`, `kamal-proxy` will stop forwarding headers to your app,
45
+ # unless you explicitly set `forward_headers: true`
46
+ #
47
+ # Defaults to `false`:
48
+ ssl: ...
49
+
50
+ # Custom SSL certificate
51
+ #
52
+ # In some cases, using Let's Encrypt for automatic certificate management is not an
53
+ # option, for example if you are running from host than one host. Or you may already
54
+ # have SSL certificates issued by a different Certificate Authority (CA).
55
+ # Kamal supports loading custom SSL certificates
56
+ # directly from secrets.
57
+ #
58
+ # Examples:
59
+ # ssl: true # Enable SSL with Let's Encrypt
60
+ # ssl: false # Disable SSL
61
+ # ssl: # Enable custom SSL
62
+ # certificate_pem: CERTIFICATE_PEM
63
+ # private_key_pem: PRIVATE_KEY_PEM
64
+ #
65
+ # ### Notes
66
+ # - If the certificate or key is missing or invalid, kamal-proxy will fail to start.
67
+ # - Always handle SSL certificates and private keys securely. Avoid hard-coding them in deploy.yml files or source control.
68
+ # - For automated certificate management, consider using the built-in Let's Encrypt integration instead.
69
+
70
+ # SSL redirect
71
+ #
72
+ # By default, kamal-proxy will redirect all HTTP requests to HTTPS when SSL is enabled.
73
+ # If you prefer that HTTP traffic is passed through to your application (along with
74
+ # HTTPS traffic), you can disable this redirect by setting `ssl_redirect: false`:
75
+ ssl_redirect: false
76
+
77
+ # Forward headers
78
+ #
79
+ # Whether to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers.
80
+ #
81
+ # If you are behind a trusted proxy, you can set this to `true` to forward the headers.
82
+ #
83
+ # By default, kamal-proxy will not forward the headers if the `ssl` option is set to `true`, and
84
+ # will forward them if it is set to `false`.
85
+ forward_headers: true
86
+
87
+ # Response timeout
88
+ #
89
+ # How long to wait for requests to complete before timing out, defaults to 30 seconds:
90
+ response_timeout: 10
91
+
92
+ # Path-based routing
93
+ #
94
+ # For applications that split their traffic to different services based on the request path,
95
+ # you can use path-based routing to mount services under different path prefixes.
96
+ path_prefix: '/api'
97
+ # By default, the path prefix will be stripped from the request before it is forwarded upstream.
98
+ # So in the example above, a request to /api/users/123 will be forwarded to web-1 as /users/123.
99
+ # To instead forward the request with the original path (including the prefix),
100
+ # specify --strip-path-prefix=false
101
+ strip_path_prefix: false
102
+
103
+ # Healthcheck
104
+ #
105
+ # When deploying, the proxy will by default hit `/up` once every second until we hit
106
+ # the deploy timeout, with a 5-second timeout for each request.
107
+ #
108
+ # Once the app is up, the proxy will stop hitting the healthcheck endpoint.
109
+ healthcheck:
110
+ interval: 3
111
+ path: /health
112
+ timeout: 3
113
+
114
+ # Buffering
115
+ #
116
+ # Whether to buffer request and response bodies in the proxy.
117
+ #
118
+ # By default, buffering is enabled with a max request body size of 1GB and no limit
119
+ # for response size.
120
+ #
121
+ # You can also set the memory limit for buffering, which defaults to 1MB; anything
122
+ # larger than that is written to disk.
123
+ buffering:
124
+ requests: true
125
+ responses: true
126
+ max_request_body: 40_000_000
127
+ max_response_body: 0
128
+ memory: 2_000_000
129
+
130
+ # Logging
131
+ #
132
+ # Configure request logging for the proxy.
133
+ # You can specify request and response headers to log.
134
+ # By default, `Cache-Control`, `Last-Modified`, and `User-Agent` request headers are logged:
135
+ logging:
136
+ request_headers:
137
+ - Cache-Control
138
+ - X-Forwarded-Proto
139
+ response_headers:
140
+ - X-Request-ID
141
+ - X-Request-Start
142
+
143
+ # Enabling/disabling the proxy on roles
144
+ #
145
+ # The proxy is enabled by default on the primary role but can be disabled by
146
+ # setting `proxy: false` in the primary role's configuration.
147
+ #
148
+ # ```yaml
149
+ # servers:
150
+ # web:
151
+ # hosts:
152
+ # - ...
153
+ # proxy: false
154
+ # ```
155
+ #
156
+ # It is disabled by default on all other roles but can be enabled by setting
157
+ # `proxy: true` or providing a proxy configuration for that role.
158
+ #
159
+ # ```yaml
160
+ # servers:
161
+ # web:
162
+ # hosts:
163
+ # - ...
164
+ # web2:
165
+ # hosts:
166
+ # - ...
167
+ # proxy: true
168
+ # ```