Add secrets for secure mount of .env local files inside Dagger

Signed-off-by: guillaume <guillaume.derouville@gmail.com>
This commit is contained in:
guillaume
2021-10-14 02:43:45 +02:00
parent 63bb368d08
commit de8cd3a52a
4 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
{
"name": "test",
"main": "index.js",
"license": {
"type": "Apache-2.0",
"url": "https://opensource.org/licenses/apache2.0.php"
},
"scripts": {
"build": "mkdir -p ./build && cp /.env ./build/env"
}
}

View File

@@ -23,3 +23,35 @@ TestReact: {
"""
}
}
TestData2: dagger.#Artifact
TestSecretsAndFile: {
pkg: #Package & {
source: TestData2
writeEnvFile: "/.env"
env: {
one: "one"
two: "two"
}
secrets: {
secretone: dagger.#Secret @dagger(input)
secretwo: dagger.#Secret @dagger(input)
}
}
test: os.#Container & {
image: alpine.#Image & {
package: bash: "=5.1.0-r0"
}
shell: path: "/bin/bash"
mount: "/build": from: pkg.build
command: """
content="$(cat /build/env)"
[[ "${content}" = *"SECRETONE="* ]] && \\
[[ "${content}" = *"SECRETWO="* ]] && \\
[[ "${content}" = *"ONE=one"* ]] && \\
[[ "${content}" = *"TWO=two"* ]]
"""
}
}