nocoffee-kamal 2.3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +13 -0
- data/bin/kamal +18 -0
- data/lib/kamal/cli/accessory.rb +287 -0
- data/lib/kamal/cli/alias/command.rb +9 -0
- data/lib/kamal/cli/app/boot.rb +125 -0
- data/lib/kamal/cli/app/prepare_assets.rb +24 -0
- data/lib/kamal/cli/app.rb +335 -0
- data/lib/kamal/cli/base.rb +198 -0
- data/lib/kamal/cli/build/clone.rb +61 -0
- data/lib/kamal/cli/build.rb +162 -0
- data/lib/kamal/cli/healthcheck/barrier.rb +33 -0
- data/lib/kamal/cli/healthcheck/error.rb +2 -0
- data/lib/kamal/cli/healthcheck/poller.rb +42 -0
- data/lib/kamal/cli/lock.rb +45 -0
- data/lib/kamal/cli/main.rb +279 -0
- data/lib/kamal/cli/proxy.rb +257 -0
- data/lib/kamal/cli/prune.rb +34 -0
- data/lib/kamal/cli/registry.rb +17 -0
- data/lib/kamal/cli/secrets.rb +43 -0
- data/lib/kamal/cli/server.rb +48 -0
- data/lib/kamal/cli/templates/deploy.yml +98 -0
- data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +3 -0
- data/lib/kamal/cli/templates/sample_hooks/post-deploy.sample +14 -0
- data/lib/kamal/cli/templates/sample_hooks/post-proxy-reboot.sample +3 -0
- data/lib/kamal/cli/templates/sample_hooks/pre-build.sample +51 -0
- data/lib/kamal/cli/templates/sample_hooks/pre-connect.sample +47 -0
- data/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample +109 -0
- data/lib/kamal/cli/templates/sample_hooks/pre-proxy-reboot.sample +3 -0
- data/lib/kamal/cli/templates/secrets +17 -0
- data/lib/kamal/cli.rb +8 -0
- data/lib/kamal/commander/specifics.rb +54 -0
- data/lib/kamal/commander.rb +176 -0
- data/lib/kamal/commands/accessory.rb +113 -0
- data/lib/kamal/commands/app/assets.rb +51 -0
- data/lib/kamal/commands/app/containers.rb +31 -0
- data/lib/kamal/commands/app/execution.rb +30 -0
- data/lib/kamal/commands/app/images.rb +13 -0
- data/lib/kamal/commands/app/logging.rb +18 -0
- data/lib/kamal/commands/app/proxy.rb +16 -0
- data/lib/kamal/commands/app.rb +115 -0
- data/lib/kamal/commands/auditor.rb +33 -0
- data/lib/kamal/commands/base.rb +98 -0
- data/lib/kamal/commands/builder/base.rb +111 -0
- data/lib/kamal/commands/builder/clone.rb +31 -0
- data/lib/kamal/commands/builder/hybrid.rb +21 -0
- data/lib/kamal/commands/builder/local.rb +14 -0
- data/lib/kamal/commands/builder/remote.rb +63 -0
- data/lib/kamal/commands/builder.rb +56 -0
- data/lib/kamal/commands/docker.rb +34 -0
- data/lib/kamal/commands/hook.rb +20 -0
- data/lib/kamal/commands/lock.rb +70 -0
- data/lib/kamal/commands/proxy.rb +87 -0
- data/lib/kamal/commands/prune.rb +38 -0
- data/lib/kamal/commands/registry.rb +14 -0
- data/lib/kamal/commands/server.rb +15 -0
- data/lib/kamal/commands.rb +2 -0
- data/lib/kamal/configuration/accessory.rb +186 -0
- data/lib/kamal/configuration/alias.rb +15 -0
- data/lib/kamal/configuration/boot.rb +25 -0
- data/lib/kamal/configuration/builder.rb +191 -0
- data/lib/kamal/configuration/docs/accessory.yml +100 -0
- data/lib/kamal/configuration/docs/alias.yml +26 -0
- data/lib/kamal/configuration/docs/boot.yml +19 -0
- data/lib/kamal/configuration/docs/builder.yml +110 -0
- data/lib/kamal/configuration/docs/configuration.yml +178 -0
- data/lib/kamal/configuration/docs/env.yml +85 -0
- data/lib/kamal/configuration/docs/logging.yml +21 -0
- data/lib/kamal/configuration/docs/proxy.yml +110 -0
- data/lib/kamal/configuration/docs/registry.yml +52 -0
- data/lib/kamal/configuration/docs/role.yml +53 -0
- data/lib/kamal/configuration/docs/servers.yml +27 -0
- data/lib/kamal/configuration/docs/ssh.yml +70 -0
- data/lib/kamal/configuration/docs/sshkit.yml +23 -0
- data/lib/kamal/configuration/env/tag.rb +13 -0
- data/lib/kamal/configuration/env.rb +29 -0
- data/lib/kamal/configuration/logging.rb +33 -0
- data/lib/kamal/configuration/proxy.rb +63 -0
- data/lib/kamal/configuration/registry.rb +32 -0
- data/lib/kamal/configuration/role.rb +220 -0
- data/lib/kamal/configuration/servers.rb +18 -0
- data/lib/kamal/configuration/ssh.rb +57 -0
- data/lib/kamal/configuration/sshkit.rb +22 -0
- data/lib/kamal/configuration/validation.rb +27 -0
- data/lib/kamal/configuration/validator/accessory.rb +9 -0
- data/lib/kamal/configuration/validator/alias.rb +15 -0
- data/lib/kamal/configuration/validator/builder.rb +13 -0
- data/lib/kamal/configuration/validator/configuration.rb +6 -0
- data/lib/kamal/configuration/validator/env.rb +54 -0
- data/lib/kamal/configuration/validator/proxy.rb +15 -0
- data/lib/kamal/configuration/validator/registry.rb +25 -0
- data/lib/kamal/configuration/validator/role.rb +11 -0
- data/lib/kamal/configuration/validator/servers.rb +7 -0
- data/lib/kamal/configuration/validator.rb +171 -0
- data/lib/kamal/configuration/volume.rb +22 -0
- data/lib/kamal/configuration.rb +393 -0
- data/lib/kamal/env_file.rb +44 -0
- data/lib/kamal/git.rb +27 -0
- data/lib/kamal/secrets/adapters/base.rb +23 -0
- data/lib/kamal/secrets/adapters/bitwarden.rb +81 -0
- data/lib/kamal/secrets/adapters/last_pass.rb +39 -0
- data/lib/kamal/secrets/adapters/one_password.rb +70 -0
- data/lib/kamal/secrets/adapters/test.rb +14 -0
- data/lib/kamal/secrets/adapters.rb +14 -0
- data/lib/kamal/secrets/dotenv/inline_command_substitution.rb +32 -0
- data/lib/kamal/secrets.rb +42 -0
- data/lib/kamal/sshkit_with_ext.rb +142 -0
- data/lib/kamal/tags.rb +40 -0
- data/lib/kamal/utils/sensitive.rb +20 -0
- data/lib/kamal/utils.rb +110 -0
- data/lib/kamal/version.rb +3 -0
- data/lib/kamal.rb +14 -0
- metadata +349 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
# Booting
|
2
|
+
#
|
3
|
+
# When deploying to large numbers of hosts, you might prefer not to restart your services on every host at the same time.
|
4
|
+
#
|
5
|
+
# Kamal’s default is to boot new containers on all hosts in parallel. However, you can control this with the boot configuration.
|
6
|
+
|
7
|
+
# Fixed group sizes
|
8
|
+
#
|
9
|
+
# Here, we boot 2 hosts at a time with a 10-second gap between each group:
|
10
|
+
boot:
|
11
|
+
limit: 2
|
12
|
+
wait: 10
|
13
|
+
|
14
|
+
# Percentage of hosts
|
15
|
+
#
|
16
|
+
# Here, we boot 25% of the hosts at a time with a 2-second gap between each group:
|
17
|
+
boot:
|
18
|
+
limit: 25%
|
19
|
+
wait: 2
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Builder
|
2
|
+
#
|
3
|
+
# The builder configuration controls how the application is built with `docker build`.
|
4
|
+
#
|
5
|
+
# See https://kamal-deploy.org/docs/configuration/builder-examples/ for more information.
|
6
|
+
|
7
|
+
# Builder options
|
8
|
+
#
|
9
|
+
# Options go under the builder key in the root configuration.
|
10
|
+
builder:
|
11
|
+
|
12
|
+
# Arch
|
13
|
+
#
|
14
|
+
# The architectures to build for — you can set an array or just a single value.
|
15
|
+
#
|
16
|
+
# Allowed values are `amd64` and `arm64`:
|
17
|
+
arch:
|
18
|
+
- amd64
|
19
|
+
|
20
|
+
# Remote
|
21
|
+
#
|
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
|
25
|
+
|
26
|
+
# Local
|
27
|
+
#
|
28
|
+
# If set to false, Kamal will always use the remote builder even when building
|
29
|
+
# the local architecture.
|
30
|
+
#
|
31
|
+
# Defaults to true:
|
32
|
+
local: true
|
33
|
+
|
34
|
+
# Builder cache
|
35
|
+
#
|
36
|
+
# The type must be either 'gha' or 'registry'.
|
37
|
+
#
|
38
|
+
# The image is only used for registry cache and is not compatible with the Docker driver:
|
39
|
+
cache:
|
40
|
+
type: registry
|
41
|
+
options: mode=max
|
42
|
+
image: kamal-app-build-cache
|
43
|
+
|
44
|
+
# Build context
|
45
|
+
#
|
46
|
+
# If this is not set, then a local Git clone of the repo is used.
|
47
|
+
# This ensures a clean build with no uncommitted changes.
|
48
|
+
#
|
49
|
+
# To use the local checkout instead, you can set the context to `.`, or a path to another directory.
|
50
|
+
context: .
|
51
|
+
|
52
|
+
# Dockerfile
|
53
|
+
#
|
54
|
+
# The Dockerfile to use for building, defaults to `Dockerfile`:
|
55
|
+
dockerfile: Dockerfile.production
|
56
|
+
|
57
|
+
# Build target
|
58
|
+
#
|
59
|
+
# If not set, then the default target is used:
|
60
|
+
target: production
|
61
|
+
|
62
|
+
# Build arguments
|
63
|
+
#
|
64
|
+
# Any additional build arguments, passed to `docker build` with `--build-arg <key>=<value>`:
|
65
|
+
args:
|
66
|
+
ENVIRONMENT: production
|
67
|
+
|
68
|
+
# Referencing build arguments
|
69
|
+
#
|
70
|
+
# ```shell
|
71
|
+
# ARG RUBY_VERSION
|
72
|
+
# FROM ruby:$RUBY_VERSION-slim as base
|
73
|
+
# ```
|
74
|
+
|
75
|
+
# Build secrets
|
76
|
+
#
|
77
|
+
# Values are read from `.kamal/secrets`:
|
78
|
+
secrets:
|
79
|
+
- SECRET1
|
80
|
+
- SECRET2
|
81
|
+
|
82
|
+
# Referencing build secrets
|
83
|
+
#
|
84
|
+
# ```shell
|
85
|
+
# # Copy Gemfiles
|
86
|
+
# COPY Gemfile Gemfile.lock ./
|
87
|
+
#
|
88
|
+
# # Install dependencies, including private repositories via access token
|
89
|
+
# # Then remove bundle cache with exposed GITHUB_TOKEN
|
90
|
+
# RUN --mount=type=secret,id=GITHUB_TOKEN \
|
91
|
+
# BUNDLE_GITHUB__COM=x-access-token:$(cat /run/secrets/GITHUB_TOKEN) \
|
92
|
+
# bundle install && \
|
93
|
+
# rm -rf /usr/local/bundle/cache
|
94
|
+
# ```
|
95
|
+
|
96
|
+
# SSH
|
97
|
+
#
|
98
|
+
# SSH agent socket or keys to expose to the build:
|
99
|
+
ssh: default=$SSH_AUTH_SOCK
|
100
|
+
|
101
|
+
# Driver
|
102
|
+
#
|
103
|
+
# The build driver to use, defaults to `docker-container`:
|
104
|
+
driver: docker
|
105
|
+
|
106
|
+
# Provenance
|
107
|
+
#
|
108
|
+
# It is used to configure provenance attestations for the build result.
|
109
|
+
# The value can also be a boolean to enable or disable provenance attestations.
|
110
|
+
provenance: mode=max
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# Kamal Configuration
|
2
|
+
#
|
3
|
+
# Configuration is read from the `config/deploy.yml`.
|
4
|
+
|
5
|
+
# Destinations
|
6
|
+
#
|
7
|
+
# When running commands, you can specify a destination with the `-d` flag,
|
8
|
+
# e.g., `kamal deploy -d staging`.
|
9
|
+
#
|
10
|
+
# In this case, the configuration will also be read from `config/deploy.staging.yml`
|
11
|
+
# and merged with the base configuration.
|
12
|
+
|
13
|
+
# Extensions
|
14
|
+
#
|
15
|
+
# Kamal will not accept unrecognized keys in the configuration file.
|
16
|
+
#
|
17
|
+
# However, you might want to declare a configuration block using YAML anchors
|
18
|
+
# and aliases to avoid repetition.
|
19
|
+
#
|
20
|
+
# You can prefix a configuration section with `x-` to indicate that it is an
|
21
|
+
# extension. Kamal will ignore the extension and not raise an error.
|
22
|
+
|
23
|
+
# The service name
|
24
|
+
#
|
25
|
+
# This is a required value. It is used as the container name prefix.
|
26
|
+
service: myapp
|
27
|
+
|
28
|
+
# The Docker image name
|
29
|
+
#
|
30
|
+
# The image will be pushed to the configured registry.
|
31
|
+
image: my-image
|
32
|
+
|
33
|
+
# Labels
|
34
|
+
#
|
35
|
+
# Additional labels to add to the container:
|
36
|
+
labels:
|
37
|
+
my-label: my-value
|
38
|
+
|
39
|
+
# Volumes
|
40
|
+
#
|
41
|
+
# Additional volumes to mount into the container:
|
42
|
+
volumes:
|
43
|
+
- /path/on/host:/path/in/container:ro
|
44
|
+
|
45
|
+
# Registry
|
46
|
+
#
|
47
|
+
# The Docker registry configuration, see kamal docs registry:
|
48
|
+
registry:
|
49
|
+
...
|
50
|
+
|
51
|
+
# Servers
|
52
|
+
#
|
53
|
+
# The servers to deploy to, optionally with custom roles, see kamal docs servers:
|
54
|
+
servers:
|
55
|
+
...
|
56
|
+
|
57
|
+
# Environment variables
|
58
|
+
#
|
59
|
+
# See kamal docs env:
|
60
|
+
env:
|
61
|
+
...
|
62
|
+
|
63
|
+
# Asset path
|
64
|
+
#
|
65
|
+
# Used for asset bridging across deployments, default to `nil`.
|
66
|
+
#
|
67
|
+
# If there are changes to CSS or JS files, we may get requests
|
68
|
+
# for the old versions on the new container, and vice versa.
|
69
|
+
#
|
70
|
+
# To avoid 404s, we can specify an asset path.
|
71
|
+
# Kamal will replace that path in the container with a mapped
|
72
|
+
# volume containing both sets of files.
|
73
|
+
# This requires that file names change when the contents change
|
74
|
+
# (e.g., by including a hash of the contents in the name).
|
75
|
+
#
|
76
|
+
# To configure this, set the path to the assets:
|
77
|
+
asset_path: /path/to/assets
|
78
|
+
|
79
|
+
# Hooks path
|
80
|
+
#
|
81
|
+
# Path to hooks, defaults to `.kamal/hooks`.
|
82
|
+
# See https://kamal-deploy.org/docs/hooks for more information:
|
83
|
+
hooks_path: /user_home/kamal/hooks
|
84
|
+
|
85
|
+
# Require destinations
|
86
|
+
#
|
87
|
+
# Whether deployments require a destination to be specified, defaults to `false`:
|
88
|
+
require_destination: true
|
89
|
+
|
90
|
+
# Primary role
|
91
|
+
#
|
92
|
+
# This defaults to `web`, but if you have no web role, you can change this:
|
93
|
+
primary_role: workers
|
94
|
+
|
95
|
+
# Allowing empty roles
|
96
|
+
#
|
97
|
+
# Whether roles with no servers are allowed. Defaults to `false`:
|
98
|
+
allow_empty_roles: false
|
99
|
+
|
100
|
+
# Retain containers
|
101
|
+
#
|
102
|
+
# How many old containers and images we retain, defaults to 5:
|
103
|
+
retain_containers: 3
|
104
|
+
|
105
|
+
# Minimum version
|
106
|
+
#
|
107
|
+
# The minimum version of Kamal required to deploy this configuration, defaults to `nil`:
|
108
|
+
minimum_version: 1.3.0
|
109
|
+
|
110
|
+
# Readiness delay
|
111
|
+
#
|
112
|
+
# Seconds to wait for a container to boot after it is running, default 7.
|
113
|
+
#
|
114
|
+
# This only applies to containers that do not run a proxy or specify a healthcheck:
|
115
|
+
readiness_delay: 4
|
116
|
+
|
117
|
+
# Deploy timeout
|
118
|
+
#
|
119
|
+
# How long to wait for a container to become ready, default 30:
|
120
|
+
deploy_timeout: 10
|
121
|
+
|
122
|
+
# Drain timeout
|
123
|
+
#
|
124
|
+
# How long to wait for a container to drain, default 30:
|
125
|
+
drain_timeout: 10
|
126
|
+
|
127
|
+
# Run directory
|
128
|
+
#
|
129
|
+
# Directory to store kamal runtime files in on the host, default `.kamal`:
|
130
|
+
run_directory: /etc/kamal
|
131
|
+
|
132
|
+
# SSH options
|
133
|
+
#
|
134
|
+
# See kamal docs ssh:
|
135
|
+
ssh:
|
136
|
+
...
|
137
|
+
|
138
|
+
# Builder options
|
139
|
+
#
|
140
|
+
# See kamal docs builder:
|
141
|
+
builder:
|
142
|
+
...
|
143
|
+
|
144
|
+
# Accessories
|
145
|
+
#
|
146
|
+
# Additional services to run in Docker, see kamal docs accessory:
|
147
|
+
accessories:
|
148
|
+
...
|
149
|
+
|
150
|
+
# Proxy
|
151
|
+
#
|
152
|
+
# Configuration for kamal-proxy, see kamal docs proxy:
|
153
|
+
proxy:
|
154
|
+
...
|
155
|
+
|
156
|
+
# SSHKit
|
157
|
+
#
|
158
|
+
# See kamal docs sshkit:
|
159
|
+
sshkit:
|
160
|
+
...
|
161
|
+
|
162
|
+
# Boot options
|
163
|
+
#
|
164
|
+
# See kamal docs boot:
|
165
|
+
boot:
|
166
|
+
...
|
167
|
+
|
168
|
+
# Logging
|
169
|
+
#
|
170
|
+
# Docker logging configuration, see kamal docs logging:
|
171
|
+
logging:
|
172
|
+
...
|
173
|
+
|
174
|
+
# Aliases
|
175
|
+
#
|
176
|
+
# Alias configuration, see kamal docs alias:
|
177
|
+
aliases:
|
178
|
+
...
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Environment variables
|
2
|
+
#
|
3
|
+
# Environment variables can be set directly in the Kamal configuration or
|
4
|
+
# read from `.kamal/secrets`.
|
5
|
+
|
6
|
+
# Reading environment variables from the configuration
|
7
|
+
#
|
8
|
+
# Environment variables can be set directly in the configuration file.
|
9
|
+
#
|
10
|
+
# These are passed to the `docker run` command when deploying.
|
11
|
+
env:
|
12
|
+
DATABASE_HOST: mysql-db1
|
13
|
+
DATABASE_PORT: 3306
|
14
|
+
|
15
|
+
# Secrets
|
16
|
+
#
|
17
|
+
# Kamal uses dotenv to automatically load environment variables set in the `.kamal/secrets` file.
|
18
|
+
#
|
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)
|
30
|
+
# ```
|
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)
|
39
|
+
# ```
|
40
|
+
#
|
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
|
44
|
+
# other variables need to be moved under the `clear` key.
|
45
|
+
#
|
46
|
+
# Unlike clear values, secrets are not passed directly to the container
|
47
|
+
# but are stored in an env file on the host:
|
48
|
+
env:
|
49
|
+
clear:
|
50
|
+
DB_USER: app
|
51
|
+
secret:
|
52
|
+
- DB_PASSWORD
|
53
|
+
|
54
|
+
# Tags
|
55
|
+
#
|
56
|
+
# Tags are used to add extra env variables to specific hosts.
|
57
|
+
# See kamal docs servers for how to tag hosts.
|
58
|
+
#
|
59
|
+
# Tags are only allowed in the top-level env configuration (i.e., not under a role-specific env).
|
60
|
+
#
|
61
|
+
# The env variables can be specified with secret and clear values as explained above.
|
62
|
+
env:
|
63
|
+
tags:
|
64
|
+
<tag1>:
|
65
|
+
MYSQL_USER: monitoring
|
66
|
+
<tag2>:
|
67
|
+
clear:
|
68
|
+
MYSQL_USER: readonly
|
69
|
+
secret:
|
70
|
+
- MYSQL_PASSWORD
|
71
|
+
|
72
|
+
# Example configuration
|
73
|
+
env:
|
74
|
+
clear:
|
75
|
+
MYSQL_USER: app
|
76
|
+
secret:
|
77
|
+
- MYSQL_PASSWORD
|
78
|
+
tags:
|
79
|
+
monitoring:
|
80
|
+
MYSQL_USER: monitoring
|
81
|
+
replica:
|
82
|
+
clear:
|
83
|
+
MYSQL_USER: readonly
|
84
|
+
secret:
|
85
|
+
- READONLY_PASSWORD
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Custom logging configuration
|
2
|
+
#
|
3
|
+
# Set these to control the Docker logging driver and options.
|
4
|
+
|
5
|
+
# Logging settings
|
6
|
+
#
|
7
|
+
# These go under the logging key in the configuration file.
|
8
|
+
#
|
9
|
+
# This can be specified at the root level or for a specific role.
|
10
|
+
logging:
|
11
|
+
|
12
|
+
# Driver
|
13
|
+
#
|
14
|
+
# The logging driver to use, passed to Docker via `--log-driver`:
|
15
|
+
driver: json-file
|
16
|
+
|
17
|
+
# Options
|
18
|
+
#
|
19
|
+
# Any logging options to pass to the driver, passed to Docker via `--log-opt`:
|
20
|
+
options:
|
21
|
+
max-size: 100m
|
@@ -0,0 +1,110 @@
|
|
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
|
+
# The proxy is enabled by default on the primary role but can be disabled by
|
14
|
+
# setting `proxy: false`.
|
15
|
+
#
|
16
|
+
# It is disabled by default on all other roles but can be enabled by setting
|
17
|
+
# `proxy: true` or providing a proxy configuration.
|
18
|
+
proxy:
|
19
|
+
|
20
|
+
# Hosts
|
21
|
+
#
|
22
|
+
# The hosts that will be used to serve the app. The proxy will only route requests
|
23
|
+
# to this host to your app.
|
24
|
+
#
|
25
|
+
# If no hosts are set, then all requests will be forwarded, except for matching
|
26
|
+
# requests for other apps deployed on that server that do have a host set.
|
27
|
+
#
|
28
|
+
# Specify one of `host` or `hosts`.
|
29
|
+
host: foo.example.com
|
30
|
+
hosts:
|
31
|
+
- foo.example.com
|
32
|
+
- bar.example.com
|
33
|
+
|
34
|
+
# App port
|
35
|
+
#
|
36
|
+
# The port the application container is exposed on.
|
37
|
+
#
|
38
|
+
# Defaults to 80:
|
39
|
+
app_port: 3000
|
40
|
+
|
41
|
+
# SSL
|
42
|
+
#
|
43
|
+
# kamal-proxy can provide automatic HTTPS for your application via Let's Encrypt.
|
44
|
+
#
|
45
|
+
# This requires that we are deploying to one server and the host option is set.
|
46
|
+
# The host value must point to the server we are deploying to, and port 443 must be
|
47
|
+
# open for the Let's Encrypt challenge to succeed.
|
48
|
+
#
|
49
|
+
# Defaults to `false`:
|
50
|
+
ssl: true
|
51
|
+
|
52
|
+
# TLSOnDemandURL
|
53
|
+
#
|
54
|
+
# Next big thing after...
|
55
|
+
tls_on_demand_url: "http://example.com/check_host"
|
56
|
+
|
57
|
+
# Response timeout
|
58
|
+
#
|
59
|
+
# How long to wait for requests to complete before timing out, defaults to 30 seconds:
|
60
|
+
response_timeout: 10
|
61
|
+
|
62
|
+
# Healthcheck
|
63
|
+
#
|
64
|
+
# When deploying, the proxy will by default hit `/up` once every second until we hit
|
65
|
+
# the deploy timeout, with a 5-second timeout for each request.
|
66
|
+
#
|
67
|
+
# Once the app is up, the proxy will stop hitting the healthcheck endpoint.
|
68
|
+
healthcheck:
|
69
|
+
interval: 3
|
70
|
+
path: /health
|
71
|
+
timeout: 3
|
72
|
+
|
73
|
+
# Buffering
|
74
|
+
#
|
75
|
+
# Whether to buffer request and response bodies in the proxy.
|
76
|
+
#
|
77
|
+
# By default, buffering is enabled with a max request body size of 1GB and no limit
|
78
|
+
# for response size.
|
79
|
+
#
|
80
|
+
# You can also set the memory limit for buffering, which defaults to 1MB; anything
|
81
|
+
# larger than that is written to disk.
|
82
|
+
buffering:
|
83
|
+
requests: true
|
84
|
+
responses: true
|
85
|
+
max_request_body: 40_000_000
|
86
|
+
max_response_body: 0
|
87
|
+
memory: 2_000_000
|
88
|
+
|
89
|
+
# Logging
|
90
|
+
#
|
91
|
+
# Configure request logging for the proxy.
|
92
|
+
# You can specify request and response headers to log.
|
93
|
+
# By default, `Cache-Control`, `Last-Modified`, and `User-Agent` request headers are logged:
|
94
|
+
logging:
|
95
|
+
request_headers:
|
96
|
+
- Cache-Control
|
97
|
+
- X-Forwarded-Proto
|
98
|
+
response_headers:
|
99
|
+
- X-Request-ID
|
100
|
+
- X-Request-Start
|
101
|
+
|
102
|
+
# Forward headers
|
103
|
+
#
|
104
|
+
# Whether to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers.
|
105
|
+
#
|
106
|
+
# If you are behind a trusted proxy, you can set this to `true` to forward the headers.
|
107
|
+
#
|
108
|
+
# By default, kamal-proxy will not forward the headers if the `ssl` option is set to `true`, and
|
109
|
+
# will forward them if it is set to `false`.
|
110
|
+
forward_headers: true
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Registry
|
2
|
+
#
|
3
|
+
# The default registry is Docker Hub, but you can change it using `registry/server`.
|
4
|
+
#
|
5
|
+
# A reference to a secret (in this case, `DOCKER_REGISTRY_TOKEN`) will look up the secret
|
6
|
+
# in the local environment:
|
7
|
+
registry:
|
8
|
+
server: registry.digitalocean.com
|
9
|
+
username:
|
10
|
+
- DOCKER_REGISTRY_TOKEN
|
11
|
+
password:
|
12
|
+
- DOCKER_REGISTRY_TOKEN
|
13
|
+
|
14
|
+
# Using AWS ECR as the container registry
|
15
|
+
#
|
16
|
+
# You will need to have the AWS CLI installed locally for this to work.
|
17
|
+
# AWS ECR’s access token is only valid for 12 hours. In order to avoid having to manually regenerate the token every time, you can use ERB in the `deploy.yml` file to shell out to the AWS CLI command and obtain the token:
|
18
|
+
registry:
|
19
|
+
server: <your aws account id>.dkr.ecr.<your aws region id>.amazonaws.com
|
20
|
+
username: AWS
|
21
|
+
password: <%= %x(aws ecr get-login-password) %>
|
22
|
+
|
23
|
+
# Using GCP Artifact Registry as the container registry
|
24
|
+
#
|
25
|
+
# To sign into Artifact Registry, you need to
|
26
|
+
# [create a service account](https://cloud.google.com/iam/docs/service-accounts-create#creating)
|
27
|
+
# and [set up roles and permissions](https://cloud.google.com/artifact-registry/docs/access-control#permissions).
|
28
|
+
# Normally, assigning the `roles/artifactregistry.writer` role should be sufficient.
|
29
|
+
#
|
30
|
+
# Once the service account is ready, you need to generate and download a JSON key and base64 encode it:
|
31
|
+
#
|
32
|
+
# ```shell
|
33
|
+
# base64 -i /path/to/key.json | tr -d "\\n"
|
34
|
+
# ```
|
35
|
+
#
|
36
|
+
# You'll then need to set the `KAMAL_REGISTRY_PASSWORD` secret to that value.
|
37
|
+
#
|
38
|
+
# Use the environment variable as the password along with `_json_key_base64` as the username.
|
39
|
+
# Here’s the final configuration:
|
40
|
+
registry:
|
41
|
+
server: <your registry region>-docker.pkg.dev
|
42
|
+
username: _json_key_base64
|
43
|
+
password:
|
44
|
+
- KAMAL_REGISTRY_PASSWORD
|
45
|
+
|
46
|
+
# Validating the configuration
|
47
|
+
#
|
48
|
+
# You can validate the configuration by running:
|
49
|
+
#
|
50
|
+
# ```shell
|
51
|
+
# kamal registry login
|
52
|
+
# ```
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Roles
|
2
|
+
#
|
3
|
+
# Roles are used to configure different types of servers in the deployment.
|
4
|
+
# The most common use for this is to run web servers and job servers.
|
5
|
+
#
|
6
|
+
# Kamal expects there to be a `web` role, unless you set a different `primary_role`
|
7
|
+
# in the root configuration.
|
8
|
+
|
9
|
+
# Role configuration
|
10
|
+
#
|
11
|
+
# Roles are specified under the servers key:
|
12
|
+
servers:
|
13
|
+
|
14
|
+
# Simple role configuration
|
15
|
+
#
|
16
|
+
# This can be a list of hosts if you don't need custom configuration for the role.
|
17
|
+
#
|
18
|
+
# You can set tags on the hosts for custom env variables (see kamal docs env):
|
19
|
+
web:
|
20
|
+
- 172.1.0.1
|
21
|
+
- 172.1.0.2: experiment1
|
22
|
+
- 172.1.0.2: [ experiment1, experiment2 ]
|
23
|
+
|
24
|
+
# Custom role configuration
|
25
|
+
#
|
26
|
+
# When there are other options to set, the list of hosts goes under the `hosts` key.
|
27
|
+
#
|
28
|
+
# By default, only the primary role uses a proxy.
|
29
|
+
#
|
30
|
+
# For other roles, you can set it to `proxy: true` to enable it and inherit the root proxy
|
31
|
+
# configuration or provide a map of options to override the root configuration.
|
32
|
+
#
|
33
|
+
# For the primary role, you can set `proxy: false` to disable the proxy.
|
34
|
+
#
|
35
|
+
# You can also set a custom `cmd` to run in the container and overwrite other settings
|
36
|
+
# from the root configuration.
|
37
|
+
workers:
|
38
|
+
hosts:
|
39
|
+
- 172.1.0.3
|
40
|
+
- 172.1.0.4: experiment1
|
41
|
+
cmd: "bin/jobs"
|
42
|
+
options:
|
43
|
+
memory: 2g
|
44
|
+
cpus: 4
|
45
|
+
logging:
|
46
|
+
...
|
47
|
+
proxy:
|
48
|
+
...
|
49
|
+
labels:
|
50
|
+
my-label: workers
|
51
|
+
env:
|
52
|
+
...
|
53
|
+
asset_path: /public
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Servers
|
2
|
+
#
|
3
|
+
# Servers are split into different roles, with each role having its own configuration.
|
4
|
+
#
|
5
|
+
# For simpler deployments, though, where all servers are identical, you can just specify a list of servers.
|
6
|
+
# They will be implicitly assigned to the `web` role.
|
7
|
+
servers:
|
8
|
+
- 172.0.0.1
|
9
|
+
- 172.0.0.2
|
10
|
+
- 172.0.0.3
|
11
|
+
|
12
|
+
# Tagging servers
|
13
|
+
#
|
14
|
+
# Servers can be tagged, with the tags used to add custom env variables (see kamal docs env).
|
15
|
+
servers:
|
16
|
+
- 172.0.0.1
|
17
|
+
- 172.0.0.2: experiments
|
18
|
+
- 172.0.0.3: [ experiments, three ]
|
19
|
+
|
20
|
+
# Roles
|
21
|
+
#
|
22
|
+
# For more complex deployments (e.g., if you are running job hosts), you can specify roles and configure each separately (see kamal docs role):
|
23
|
+
servers:
|
24
|
+
web:
|
25
|
+
...
|
26
|
+
workers:
|
27
|
+
...
|