Use env files for secrets
Add env files back in for secrets - hides them from process lists and allows you to pick up the latest env file when running `kamal app exec` without reusing.
This commit is contained in:
@@ -51,7 +51,19 @@ class Kamal::Configuration::Accessory
|
||||
end
|
||||
|
||||
def env_args
|
||||
env.args
|
||||
[ *env.clear_args, *argumentize("--env-file", secrets_path) ]
|
||||
end
|
||||
|
||||
def env_directory
|
||||
File.join(config.env_directory, "accessories")
|
||||
end
|
||||
|
||||
def secrets_io
|
||||
env.secrets_io
|
||||
end
|
||||
|
||||
def secrets_path
|
||||
File.join(config.env_directory, "accessories", "#{service_name}.env")
|
||||
end
|
||||
|
||||
def files
|
||||
|
||||
@@ -13,8 +13,12 @@ class Kamal::Configuration::Env
|
||||
validate! config, context: context, with: Kamal::Configuration::Validator::Env
|
||||
end
|
||||
|
||||
def args
|
||||
[ *clear_args, *secret_args ]
|
||||
def clear_args
|
||||
argumentize("--env", clear)
|
||||
end
|
||||
|
||||
def secrets_io
|
||||
Kamal::EnvFile.new(secret_keys.to_h { |key| [ key, secrets[key] ] }).to_io
|
||||
end
|
||||
|
||||
def merge(other)
|
||||
@@ -22,13 +26,4 @@ class Kamal::Configuration::Env
|
||||
config: { "clear" => clear.merge(other.clear), "secret" => secret_keys | other.secret_keys },
|
||||
secrets: secrets
|
||||
end
|
||||
|
||||
private
|
||||
def clear_args
|
||||
argumentize("--env", clear)
|
||||
end
|
||||
|
||||
def secret_args
|
||||
argumentize("--env", secret_keys.to_h { |key| [ key, secrets[key] ] }, sensitive: true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +77,19 @@ class Kamal::Configuration::Role
|
||||
end
|
||||
|
||||
def env_args(host)
|
||||
env(host).args
|
||||
[ *env(host).clear_args, *argumentize("--env-file", secrets_path) ]
|
||||
end
|
||||
|
||||
def env_directory
|
||||
File.join(config.env_directory, "roles")
|
||||
end
|
||||
|
||||
def secrets_io(host)
|
||||
env(host).secrets_io
|
||||
end
|
||||
|
||||
def secrets_path
|
||||
File.join(config.env_directory, "roles", "#{container_prefix}.env")
|
||||
end
|
||||
|
||||
def asset_volume_args
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Kamal::Configuration::Traefik
|
||||
delegate :argumentize, to: Kamal::Utils
|
||||
|
||||
DEFAULT_IMAGE = "traefik:v2.10"
|
||||
CONTAINER_PORT = 80
|
||||
DEFAULT_ARGS = {
|
||||
@@ -57,4 +59,20 @@ class Kamal::Configuration::Traefik
|
||||
def image
|
||||
traefik_config.fetch("image", DEFAULT_IMAGE)
|
||||
end
|
||||
|
||||
def env_args
|
||||
[ *env.clear_args, *argumentize("--env-file", secrets_path) ]
|
||||
end
|
||||
|
||||
def env_directory
|
||||
File.join(config.env_directory, "traefik")
|
||||
end
|
||||
|
||||
def secrets_io
|
||||
env.secrets_io
|
||||
end
|
||||
|
||||
def secrets_path
|
||||
File.join(config.env_directory, "traefik", "traefik.env")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user