forked from hercules-ci/arion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for docker compose secrets
enables using [docker compose secrets](https://docs.docker.com/compose/use-secrets/) from arion, which includes: - [top-level `secrets` element](https://docs.docker.com/compose/compose-file/09-secrets/) defining the secrets to be used for the below two use-cases, exposing them at `/run/secrets/<secret_name>`. comes in flavors `file` vs `environment`. - run-time: [`services` top-level `secrets` element](https://docs.docker.com/compose/compose-file/05-services/#secrets) - build time: [build secrets](https://docs.docker.com/build/building/secrets/) (to be [mounted](https://docs.docker.com/build/building/secrets/#secret-mounts) in the `Dockerfile` like `RUN --mount=type=secret,id=<secret_name> ...`) unlike hercules-ci#52, i did not so far add support for their [long syntax](https://docs.docker.com/compose/compose-file/05-services/#long-syntax-4), which despite the confusing documentation appears [limited to Docker Swarm](docker/compose#9648 (comment)), in my understanding limiting its use in Arion.
- Loading branch information
1 parent
236f9dd
commit a8b2157
Showing
10 changed files
with
167 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"name": "unit-test-data" | ||
} | ||
}, | ||
"secrets": {}, | ||
"services": { | ||
"webserver": { | ||
"command": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ config, lib, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkOption | ||
types | ||
; | ||
inherit (import ../../lib.nix { inherit lib; }) | ||
link | ||
; | ||
in | ||
{ | ||
|
||
options = { | ||
secrets = mkOption { | ||
type = types.lazyAttrsOf (types.submoduleWith { | ||
modules = [ | ||
../secrets/secret.nix | ||
]; | ||
}); | ||
description = '' | ||
See ${link "https://docs.docker.com/compose/compose-file/09-secrets/" "Docker Compose Secrets"} | ||
''; | ||
}; | ||
}; | ||
|
||
config = { | ||
|
||
secrets = {}; | ||
docker-compose.secrets = lib.mapAttrs (k: v: v.out) config.secrets; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ config, lib, options, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkOption | ||
optionalAttrs | ||
types | ||
; | ||
inherit (import ../../lib.nix { inherit lib; }) | ||
secretRef | ||
; | ||
in | ||
{ | ||
options = { | ||
file = mkOption { | ||
description = '' | ||
The secret is created with the contents of the file at the specified path. | ||
${secretRef "file"} | ||
''; | ||
type = types.nullOr types.str; | ||
}; | ||
|
||
environment = mkOption { | ||
description = '' | ||
The secret is created with the value of an environment variable. | ||
${secretRef "environment"} | ||
''; | ||
type = types.nullOr types.str; | ||
}; | ||
|
||
out = mkOption { | ||
internal = true; | ||
description = '' | ||
Defines sensitive data that is granted to the services in your Compose application. | ||
The source of the secret is either `file` or `environment`. | ||
''; | ||
type = lib.types.attrsOf lib.types.raw or lib.types.unspecified; | ||
}; | ||
}; | ||
|
||
config = { | ||
out = | ||
lib.mapAttrs | ||
(k: opt: opt.value) | ||
(lib.filterAttrs | ||
(k: opt: opt.isDefined) | ||
{ | ||
inherit (options) | ||
file | ||
environment | ||
; | ||
} | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters