kamal-insecure 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 +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +13 -0
  4. data/bin/kamal +18 -0
  5. data/lib/kamal/cli/accessory.rb +313 -0
  6. data/lib/kamal/cli/alias/command.rb +10 -0
  7. data/lib/kamal/cli/app/assets.rb +24 -0
  8. data/lib/kamal/cli/app/boot.rb +126 -0
  9. data/lib/kamal/cli/app/error_pages.rb +33 -0
  10. data/lib/kamal/cli/app/ssl_certificates.rb +28 -0
  11. data/lib/kamal/cli/app.rb +400 -0
  12. data/lib/kamal/cli/base.rb +223 -0
  13. data/lib/kamal/cli/build/clone.rb +61 -0
  14. data/lib/kamal/cli/build.rb +204 -0
  15. data/lib/kamal/cli/healthcheck/barrier.rb +33 -0
  16. data/lib/kamal/cli/healthcheck/error.rb +2 -0
  17. data/lib/kamal/cli/healthcheck/poller.rb +42 -0
  18. data/lib/kamal/cli/lock.rb +45 -0
  19. data/lib/kamal/cli/main.rb +277 -0
  20. data/lib/kamal/cli/proxy.rb +290 -0
  21. data/lib/kamal/cli/prune.rb +34 -0
  22. data/lib/kamal/cli/registry.rb +19 -0
  23. data/lib/kamal/cli/secrets.rb +49 -0
  24. data/lib/kamal/cli/server.rb +50 -0
  25. data/lib/kamal/cli/templates/deploy.yml +101 -0
  26. data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +3 -0
  27. data/lib/kamal/cli/templates/sample_hooks/post-app-boot.sample +3 -0
  28. data/lib/kamal/cli/templates/sample_hooks/post-deploy.sample +14 -0
  29. data/lib/kamal/cli/templates/sample_hooks/post-proxy-reboot.sample +3 -0
  30. data/lib/kamal/cli/templates/sample_hooks/pre-app-boot.sample +3 -0
  31. data/lib/kamal/cli/templates/sample_hooks/pre-build.sample +51 -0
  32. data/lib/kamal/cli/templates/sample_hooks/pre-connect.sample +47 -0
  33. data/lib/kamal/cli/templates/sample_hooks/pre-deploy.sample +122 -0
  34. data/lib/kamal/cli/templates/sample_hooks/pre-proxy-reboot.sample +3 -0
  35. data/lib/kamal/cli/templates/secrets +17 -0
  36. data/lib/kamal/cli.rb +9 -0
  37. data/lib/kamal/commander/specifics.rb +62 -0
  38. data/lib/kamal/commander.rb +167 -0
  39. data/lib/kamal/commands/accessory/proxy.rb +16 -0
  40. data/lib/kamal/commands/accessory.rb +113 -0
  41. data/lib/kamal/commands/app/assets.rb +51 -0
  42. data/lib/kamal/commands/app/containers.rb +31 -0
  43. data/lib/kamal/commands/app/error_pages.rb +9 -0
  44. data/lib/kamal/commands/app/execution.rb +32 -0
  45. data/lib/kamal/commands/app/images.rb +13 -0
  46. data/lib/kamal/commands/app/logging.rb +28 -0
  47. data/lib/kamal/commands/app/proxy.rb +32 -0
  48. data/lib/kamal/commands/app.rb +124 -0
  49. data/lib/kamal/commands/auditor.rb +39 -0
  50. data/lib/kamal/commands/base.rb +134 -0
  51. data/lib/kamal/commands/builder/base.rb +124 -0
  52. data/lib/kamal/commands/builder/clone.rb +31 -0
  53. data/lib/kamal/commands/builder/cloud.rb +22 -0
  54. data/lib/kamal/commands/builder/hybrid.rb +21 -0
  55. data/lib/kamal/commands/builder/local.rb +14 -0
  56. data/lib/kamal/commands/builder/pack.rb +46 -0
  57. data/lib/kamal/commands/builder/remote.rb +63 -0
  58. data/lib/kamal/commands/builder.rb +48 -0
  59. data/lib/kamal/commands/docker.rb +34 -0
  60. data/lib/kamal/commands/hook.rb +20 -0
  61. data/lib/kamal/commands/lock.rb +70 -0
  62. data/lib/kamal/commands/proxy.rb +127 -0
  63. data/lib/kamal/commands/prune.rb +38 -0
  64. data/lib/kamal/commands/registry.rb +16 -0
  65. data/lib/kamal/commands/server.rb +15 -0
  66. data/lib/kamal/commands.rb +2 -0
  67. data/lib/kamal/configuration/accessory.rb +241 -0
  68. data/lib/kamal/configuration/alias.rb +15 -0
  69. data/lib/kamal/configuration/boot.rb +25 -0
  70. data/lib/kamal/configuration/builder.rb +211 -0
  71. data/lib/kamal/configuration/docs/accessory.yml +128 -0
  72. data/lib/kamal/configuration/docs/alias.yml +26 -0
  73. data/lib/kamal/configuration/docs/boot.yml +19 -0
  74. data/lib/kamal/configuration/docs/builder.yml +132 -0
  75. data/lib/kamal/configuration/docs/configuration.yml +184 -0
  76. data/lib/kamal/configuration/docs/env.yml +116 -0
  77. data/lib/kamal/configuration/docs/logging.yml +21 -0
  78. data/lib/kamal/configuration/docs/proxy.yml +164 -0
  79. data/lib/kamal/configuration/docs/registry.yml +56 -0
  80. data/lib/kamal/configuration/docs/role.yml +53 -0
  81. data/lib/kamal/configuration/docs/servers.yml +27 -0
  82. data/lib/kamal/configuration/docs/ssh.yml +70 -0
  83. data/lib/kamal/configuration/docs/sshkit.yml +23 -0
  84. data/lib/kamal/configuration/env/tag.rb +13 -0
  85. data/lib/kamal/configuration/env.rb +38 -0
  86. data/lib/kamal/configuration/logging.rb +33 -0
  87. data/lib/kamal/configuration/proxy/boot.rb +129 -0
  88. data/lib/kamal/configuration/proxy.rb +124 -0
  89. data/lib/kamal/configuration/registry.rb +32 -0
  90. data/lib/kamal/configuration/role.rb +222 -0
  91. data/lib/kamal/configuration/servers.rb +25 -0
  92. data/lib/kamal/configuration/ssh.rb +57 -0
  93. data/lib/kamal/configuration/sshkit.rb +22 -0
  94. data/lib/kamal/configuration/validation.rb +27 -0
  95. data/lib/kamal/configuration/validator/accessory.rb +13 -0
  96. data/lib/kamal/configuration/validator/alias.rb +15 -0
  97. data/lib/kamal/configuration/validator/builder.rb +15 -0
  98. data/lib/kamal/configuration/validator/configuration.rb +6 -0
  99. data/lib/kamal/configuration/validator/env.rb +54 -0
  100. data/lib/kamal/configuration/validator/proxy.rb +25 -0
  101. data/lib/kamal/configuration/validator/registry.rb +25 -0
  102. data/lib/kamal/configuration/validator/role.rb +13 -0
  103. data/lib/kamal/configuration/validator/servers.rb +7 -0
  104. data/lib/kamal/configuration/validator.rb +191 -0
  105. data/lib/kamal/configuration/volume.rb +22 -0
  106. data/lib/kamal/configuration.rb +372 -0
  107. data/lib/kamal/docker.rb +30 -0
  108. data/lib/kamal/env_file.rb +44 -0
  109. data/lib/kamal/git.rb +37 -0
  110. data/lib/kamal/secrets/adapters/aws_secrets_manager.rb +51 -0
  111. data/lib/kamal/secrets/adapters/base.rb +33 -0
  112. data/lib/kamal/secrets/adapters/bitwarden.rb +81 -0
  113. data/lib/kamal/secrets/adapters/bitwarden_secrets_manager.rb +66 -0
  114. data/lib/kamal/secrets/adapters/doppler.rb +57 -0
  115. data/lib/kamal/secrets/adapters/enpass.rb +71 -0
  116. data/lib/kamal/secrets/adapters/gcp_secret_manager.rb +112 -0
  117. data/lib/kamal/secrets/adapters/last_pass.rb +40 -0
  118. data/lib/kamal/secrets/adapters/one_password.rb +104 -0
  119. data/lib/kamal/secrets/adapters/passbolt.rb +130 -0
  120. data/lib/kamal/secrets/adapters/test.rb +14 -0
  121. data/lib/kamal/secrets/adapters.rb +16 -0
  122. data/lib/kamal/secrets/dotenv/inline_command_substitution.rb +33 -0
  123. data/lib/kamal/secrets.rb +42 -0
  124. data/lib/kamal/sshkit_with_ext.rb +142 -0
  125. data/lib/kamal/tags.rb +40 -0
  126. data/lib/kamal/utils/sensitive.rb +20 -0
  127. data/lib/kamal/utils.rb +110 -0
  128. data/lib/kamal/version.rb +3 -0
  129. data/lib/kamal.rb +14 -0
  130. metadata +365 -0
@@ -0,0 +1,116 @@
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
+ # 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
+
85
+ # Tags
86
+ #
87
+ # Tags are used to add extra env variables to specific hosts.
88
+ # See kamal docs servers for how to tag hosts.
89
+ #
90
+ # Tags are only allowed in the top-level env configuration (i.e., not under a role-specific env).
91
+ #
92
+ # The env variables can be specified with secret and clear values as explained above.
93
+ env:
94
+ tags:
95
+ <tag1>:
96
+ MYSQL_USER: monitoring
97
+ <tag2>:
98
+ clear:
99
+ MYSQL_USER: readonly
100
+ secret:
101
+ - MYSQL_PASSWORD
102
+
103
+ # Example configuration
104
+ env:
105
+ clear:
106
+ MYSQL_USER: app
107
+ secret:
108
+ - MYSQL_PASSWORD
109
+ tags:
110
+ monitoring:
111
+ MYSQL_USER: monitoring
112
+ replica:
113
+ clear:
114
+ MYSQL_USER: readonly
115
+ secret:
116
+ - 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,164 @@
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: true
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 more than one host.
54
+ #
55
+ # Or you may already have SSL certificates issued by a different Certificate Authority (CA).
56
+ #
57
+ # Kamal supports loading custom SSL certificates directly from secrets. You should
58
+ # pass a hash mapping the `certificate_pem` and `private_key_pem` to the secret names.
59
+ ssl:
60
+ certificate_pem: CERTIFICATE_PEM
61
+ private_key_pem: PRIVATE_KEY_PEM
62
+ # ### Notes
63
+ # - If the certificate or key is missing or invalid, deployments will fail.
64
+ # - Always handle SSL certificates and private keys securely. Avoid hard-coding them in source control.
65
+
66
+ # SSL redirect
67
+ #
68
+ # By default, kamal-proxy will redirect all HTTP requests to HTTPS when SSL is enabled.
69
+ # If you prefer that HTTP traffic is passed through to your application (along with
70
+ # HTTPS traffic), you can disable this redirect by setting `ssl_redirect: false`:
71
+ ssl_redirect: false
72
+
73
+ # Forward headers
74
+ #
75
+ # Whether to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers.
76
+ #
77
+ # If you are behind a trusted proxy, you can set this to `true` to forward the headers.
78
+ #
79
+ # By default, kamal-proxy will not forward the headers if the `ssl` option is set to `true`, and
80
+ # will forward them if it is set to `false`.
81
+ forward_headers: true
82
+
83
+ # Response timeout
84
+ #
85
+ # How long to wait for requests to complete before timing out, defaults to 30 seconds:
86
+ response_timeout: 10
87
+
88
+ # Path-based routing
89
+ #
90
+ # For applications that split their traffic to different services based on the request path,
91
+ # you can use path-based routing to mount services under different path prefixes.
92
+ path_prefix: '/api'
93
+ # By default, the path prefix will be stripped from the request before it is forwarded upstream.
94
+ # So in the example above, a request to /api/users/123 will be forwarded to web-1 as /users/123.
95
+ # To instead forward the request with the original path (including the prefix),
96
+ # specify --strip-path-prefix=false
97
+ strip_path_prefix: false
98
+
99
+ # Healthcheck
100
+ #
101
+ # When deploying, the proxy will by default hit `/up` once every second until we hit
102
+ # the deploy timeout, with a 5-second timeout for each request.
103
+ #
104
+ # Once the app is up, the proxy will stop hitting the healthcheck endpoint.
105
+ healthcheck:
106
+ interval: 3
107
+ path: /health
108
+ timeout: 3
109
+
110
+ # Buffering
111
+ #
112
+ # Whether to buffer request and response bodies in the proxy.
113
+ #
114
+ # By default, buffering is enabled with a max request body size of 1GB and no limit
115
+ # for response size.
116
+ #
117
+ # You can also set the memory limit for buffering, which defaults to 1MB; anything
118
+ # larger than that is written to disk.
119
+ buffering:
120
+ requests: true
121
+ responses: true
122
+ max_request_body: 40_000_000
123
+ max_response_body: 0
124
+ memory: 2_000_000
125
+
126
+ # Logging
127
+ #
128
+ # Configure request logging for the proxy.
129
+ # You can specify request and response headers to log.
130
+ # By default, `Cache-Control`, `Last-Modified`, and `User-Agent` request headers are logged:
131
+ logging:
132
+ request_headers:
133
+ - Cache-Control
134
+ - X-Forwarded-Proto
135
+ response_headers:
136
+ - X-Request-ID
137
+ - X-Request-Start
138
+
139
+ # Enabling/disabling the proxy on roles
140
+ #
141
+ # The proxy is enabled by default on the primary role but can be disabled by
142
+ # setting `proxy: false` in the primary role's configuration.
143
+ #
144
+ # ```yaml
145
+ # servers:
146
+ # web:
147
+ # hosts:
148
+ # - ...
149
+ # proxy: false
150
+ # ```
151
+ #
152
+ # It is disabled by default on all other roles but can be enabled by setting
153
+ # `proxy: true` or providing a proxy configuration for that role.
154
+ #
155
+ # ```yaml
156
+ # servers:
157
+ # web:
158
+ # hosts:
159
+ # - ...
160
+ # web2:
161
+ # hosts:
162
+ # - ...
163
+ # proxy: true
164
+ # ```
@@ -0,0 +1,56 @@
1
+ # Registry
2
+ #
3
+ # The default registry is Docker Hub, but you can change it using `registry/server`.
4
+ #
5
+ # By default, Docker Hub creates public repositories. To avoid making your images public,
6
+ # set up a private repository before deploying, or change the default repository privacy
7
+ # settings to private in your [Docker Hub settings](https://hub.docker.com/repository-settings/default-privacy).
8
+ #
9
+ # A reference to a secret (in this case, `DOCKER_REGISTRY_TOKEN`) will look up the secret
10
+ # in the local environment:
11
+ registry:
12
+ server: registry.digitalocean.com
13
+ username:
14
+ - DOCKER_REGISTRY_TOKEN
15
+ password:
16
+ - DOCKER_REGISTRY_TOKEN
17
+
18
+ # Using AWS ECR as the container registry
19
+ #
20
+ # You will need to have the AWS CLI installed locally for this to work.
21
+ # 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:
22
+ registry:
23
+ server: <your aws account id>.dkr.ecr.<your aws region id>.amazonaws.com
24
+ username: AWS
25
+ password: <%= %x(aws ecr get-login-password) %>
26
+
27
+ # Using GCP Artifact Registry as the container registry
28
+ #
29
+ # To sign into Artifact Registry, you need to
30
+ # [create a service account](https://cloud.google.com/iam/docs/service-accounts-create#creating)
31
+ # and [set up roles and permissions](https://cloud.google.com/artifact-registry/docs/access-control#permissions).
32
+ # Normally, assigning the `roles/artifactregistry.writer` role should be sufficient.
33
+ #
34
+ # Once the service account is ready, you need to generate and download a JSON key and base64 encode it:
35
+ #
36
+ # ```shell
37
+ # base64 -i /path/to/key.json | tr -d "\\n"
38
+ # ```
39
+ #
40
+ # You'll then need to set the `KAMAL_REGISTRY_PASSWORD` secret to that value.
41
+ #
42
+ # Use the environment variable as the password along with `_json_key_base64` as the username.
43
+ # Here’s the final configuration:
44
+ registry:
45
+ server: <your registry region>-docker.pkg.dev
46
+ username: _json_key_base64
47
+ password:
48
+ - KAMAL_REGISTRY_PASSWORD
49
+
50
+ # Validating the configuration
51
+ #
52
+ # You can validate the configuration by running:
53
+ #
54
+ # ```shell
55
+ # kamal registry login
56
+ # ```
@@ -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
+ ...
@@ -0,0 +1,70 @@
1
+ # SSH configuration
2
+ #
3
+ # Kamal uses SSH to connect and run commands on your hosts.
4
+ # By default, it will attempt to connect to the root user on port 22.
5
+ #
6
+ # If you are using a non-root user, you may need to bootstrap your servers manually before using them with Kamal. On Ubuntu, you’d do:
7
+ #
8
+ # ```shell
9
+ # sudo apt update
10
+ # sudo apt upgrade -y
11
+ # sudo apt install -y docker.io curl git
12
+ # sudo usermod -a -G docker app
13
+ # ```
14
+
15
+ # SSH options
16
+ #
17
+ # The options are specified under the ssh key in the configuration file.
18
+ ssh:
19
+
20
+ # The SSH user
21
+ #
22
+ # Defaults to `root`:
23
+ user: app
24
+
25
+ # The SSH port
26
+ #
27
+ # Defaults to 22:
28
+ port: "2222"
29
+
30
+ # Proxy host
31
+ #
32
+ # Specified in the form <host> or <user>@<host>:
33
+ proxy: root@proxy-host
34
+
35
+ # Proxy command
36
+ #
37
+ # A custom proxy command, required for older versions of SSH:
38
+ proxy_command: "ssh -W %h:%p user@proxy"
39
+
40
+ # Log level
41
+ #
42
+ # Defaults to `fatal`. Set this to `debug` if you are having SSH connection issues.
43
+ log_level: debug
44
+
45
+ # Keys only
46
+ #
47
+ # Set to `true` to use only private keys from the `keys` and `key_data` parameters,
48
+ # even if ssh-agent offers more identities. This option is intended for
49
+ # situations where ssh-agent offers many different identities or you
50
+ # need to overwrite all identities and force a single one.
51
+ keys_only: false
52
+
53
+ # Keys
54
+ #
55
+ # An array of file names of private keys to use for public key
56
+ # and host-based authentication:
57
+ keys: [ "~/.ssh/id.pem" ]
58
+
59
+ # Key data
60
+ #
61
+ # An array of strings, with each element of the array being
62
+ # a raw private key in PEM format.
63
+ key_data: [ "-----BEGIN OPENSSH PRIVATE KEY-----" ]
64
+
65
+ # Config
66
+ #
67
+ # Set to true to load the default OpenSSH config files (~/.ssh/config,
68
+ # /etc/ssh_config), to false ignore config files, or to a file path
69
+ # (or array of paths) to load specific configuration. Defaults to true.
70
+ config: true
@@ -0,0 +1,23 @@
1
+ # SSHKit
2
+ #
3
+ # [SSHKit](https://github.com/capistrano/sshkit) is the SSH toolkit used by Kamal.
4
+ #
5
+ # The default, settings should be sufficient for most use cases, but
6
+ # when connecting to a large number of hosts, you may need to adjust.
7
+
8
+ # SSHKit options
9
+ #
10
+ # The options are specified under the sshkit key in the configuration file.
11
+ sshkit:
12
+
13
+ # Max concurrent starts
14
+ #
15
+ # Creating SSH connections concurrently can be an issue when deploying to many servers.
16
+ # By default, Kamal will limit concurrent connection starts to 30 at a time.
17
+ max_concurrent_starts: 10
18
+
19
+ # Pool idle timeout
20
+ #
21
+ # Kamal sets a long idle timeout of 900 seconds on connections to try to avoid
22
+ # re-connection storms after an idle period, such as building an image or waiting for CI.
23
+ pool_idle_timeout: 300
@@ -0,0 +1,13 @@
1
+ class Kamal::Configuration::Env::Tag
2
+ attr_reader :name, :config, :secrets
3
+
4
+ def initialize(name, config:, secrets:)
5
+ @name = name
6
+ @config = config
7
+ @secrets = secrets
8
+ end
9
+
10
+ def env
11
+ Kamal::Configuration::Env.new(config: config, secrets: secrets)
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ class Kamal::Configuration::Env
2
+ include Kamal::Configuration::Validation
3
+
4
+ attr_reader :context, :clear, :secret_keys
5
+ delegate :argumentize, to: Kamal::Utils
6
+
7
+ def initialize(config:, secrets:, context: "env")
8
+ @clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config)
9
+ @secrets = secrets
10
+ @secret_keys = config.fetch("secret", [])
11
+ @context = context
12
+ validate! config, context: context, with: Kamal::Configuration::Validator::Env
13
+ end
14
+
15
+ def clear_args
16
+ argumentize("--env", clear)
17
+ end
18
+
19
+ def secrets_io
20
+ Kamal::EnvFile.new(aliased_secrets).to_io
21
+ end
22
+
23
+ def merge(other)
24
+ self.class.new \
25
+ config: { "clear" => clear.merge(other.clear), "secret" => secret_keys | other.secret_keys },
26
+ secrets: @secrets
27
+ end
28
+
29
+ private
30
+ def aliased_secrets
31
+ secret_keys.to_h { |key| extract_alias(key) }.transform_values { |secret_key| @secrets[secret_key] }
32
+ end
33
+
34
+ def extract_alias(key)
35
+ key_name, key_aliased_to = key.split(":", 2)
36
+ [ key_name, key_aliased_to || key_name ]
37
+ end
38
+ end
@@ -0,0 +1,33 @@
1
+ class Kamal::Configuration::Logging
2
+ delegate :optionize, :argumentize, to: Kamal::Utils
3
+
4
+ include Kamal::Configuration::Validation
5
+
6
+ attr_reader :logging_config
7
+
8
+ def initialize(logging_config:, context: "logging")
9
+ @logging_config = logging_config || {}
10
+ validate! @logging_config, context: context
11
+ end
12
+
13
+ def driver
14
+ logging_config["driver"]
15
+ end
16
+
17
+ def options
18
+ logging_config.fetch("options", {})
19
+ end
20
+
21
+ def merge(other)
22
+ self.class.new logging_config: logging_config.deep_merge(other.logging_config)
23
+ end
24
+
25
+ def args
26
+ if driver.present? || options.present?
27
+ optionize({ "log-driver" => driver }.compact) +
28
+ argumentize("--log-opt", options)
29
+ else
30
+ argumentize("--log-opt", { "max-size" => "10m" })
31
+ end
32
+ end
33
+ end