Add compose.#Up test in universe
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
2
stdlib/.dagger/env/docker-compose-simple/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/docker-compose-simple/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# dagger state
|
||||
state/**
|
85
stdlib/.dagger/env/docker-compose-simple/plan/cleanup.cue
vendored
Normal file
85
stdlib/.dagger/env/docker-compose-simple/plan/cleanup.cue
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
#CleanupCompose: {
|
||||
// docker-compose up context
|
||||
context: dagger.#Artifact
|
||||
|
||||
ssh: {
|
||||
// ssh host
|
||||
host: string @dagger(input)
|
||||
|
||||
// ssh user
|
||||
user: string @dagger(input)
|
||||
|
||||
// ssh port
|
||||
port: *22 | int @dagger(input)
|
||||
|
||||
// private key
|
||||
key: dagger.#Secret @dagger(input)
|
||||
|
||||
// fingerprint
|
||||
fingerprint?: string @dagger(input)
|
||||
|
||||
// ssh key passphrase
|
||||
keyPassphrase?: dagger.#Secret @dagger(input)
|
||||
}
|
||||
|
||||
#code: #"""
|
||||
# Export host
|
||||
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||
|
||||
# Start ssh agent
|
||||
eval $(ssh-agent) > /dev/null
|
||||
ssh-add /key > /dev/null
|
||||
|
||||
ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true
|
||||
|
||||
# Down
|
||||
docker-compose down -v
|
||||
"""#
|
||||
|
||||
#up: [
|
||||
op.#Load & {from: context},
|
||||
|
||||
op.#WriteFile & {
|
||||
content: #code
|
||||
dest: "/entrypoint.sh"
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"/bin/sh",
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo",
|
||||
"pipefail",
|
||||
"/entrypoint.sh",
|
||||
]
|
||||
env: {
|
||||
DOCKER_HOSTNAME: ssh.host
|
||||
DOCKER_USERNAME: ssh.user
|
||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||
if ssh.keyPassphrase != _|_ {
|
||||
SSH_ASKPASS: "/get_passphrase"
|
||||
DISPLAY: "1"
|
||||
}
|
||||
}
|
||||
mount: {
|
||||
if ssh.key != _|_ {
|
||||
"/key": secret: ssh.key
|
||||
}
|
||||
if ssh.keyPassphrase != _|_ {
|
||||
"/passphrase": secret: ssh.keyPassphrase
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
37
stdlib/.dagger/env/docker-compose-simple/plan/compose.cue
vendored
Normal file
37
stdlib/.dagger/env/docker-compose-simple/plan/compose.cue
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"dagger.io/docker"
|
||||
"dagger.io/docker/compose"
|
||||
)
|
||||
|
||||
TestCompose: {
|
||||
up: compose.#Up & {
|
||||
ssh: {
|
||||
host: "143.198.64.230"
|
||||
user: "root"
|
||||
}
|
||||
composeFile: #"""
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- 8000:80
|
||||
"""#
|
||||
}
|
||||
|
||||
verify: docker.#Command & {
|
||||
ssh: up.run.ssh
|
||||
command: #"""
|
||||
docker container ls | grep "nginx" | grep "Up"
|
||||
"""#
|
||||
}
|
||||
|
||||
// Can't simply use docker.#Command because we need to keep docker-compose context
|
||||
cleanup: #CleanupCompose & {
|
||||
context: up.run
|
||||
ssh: verify.ssh
|
||||
}
|
||||
}
|
26
stdlib/.dagger/env/docker-compose-simple/values.yaml
vendored
Normal file
26
stdlib/.dagger/env/docker-compose-simple/values.yaml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
plan:
|
||||
module: .dagger/env/docker-compose-simple/plan
|
||||
name: docker-compose-simple
|
||||
inputs:
|
||||
TestCompose.up.ssh.key:
|
||||
secret: ENC[AES256_GCM,data:abxRdizVf/D9A9XI1xnQKaQrwRYHu12Ene3MmyooqxnqLtOB2Y03YtdfL2MAJLB73ulWYAXWOEcefU8+DghnkCQ94EenDNmnbuAJvXOdqgo0g4Uik1jXUpC6D81YQCFQmqTzsNoh0Rom+bKZK8boVVSEyLr7cgjEtAsAfIgns4B0uVe5l5XaHw+vfSXP3hraxZjbXUdv6qPKtkTWzeu2ywvUEzc7zm7XCHXWsZDzuyKaGJThxZu6upiHRuMdsJ7JSNJMdZ9AOAVMTfD0miYFOuj6mdlYshtR+6lWo86i+LKXdILsUi9cerapqvFV+rjN31hS2Y1dY5O0O/rQOhPv7LcbpAKzkQsnY4giKf8oBwfn2v7roA7C+b1P1GeknQZaozckV644mJPLztfukJjhFjZ8qWHkv/jpdetm1FQJSDkBs2o3EqPbZJLFdyvui6g50dNdP48sdzuxONLH8vPwHrkjkUp4QK9mMd/Fhva0G/dgnO49h/pAVqicketnlQnl+V8RUpWAxHVRRAZ4CmGj2M4XtePnPXsTeysi,iv:EftAI98PVgOWaI63T1Isbe0EpjRIxaUYYmAe7i19J8Q=,tag:4OJHMVVfbbY8KNWG4va/pg==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
age:
|
||||
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAyMUJoZHN0NVFCd1d1bXUv
|
||||
ZCtPUmltRmJCcnE3WHhheGRjOE5Yby95Mmd3CmJKTzBQYXNyRHVKcTQrZUNWL3pC
|
||||
TnNhZmFJeGJCRmJ4UkVMMlZxUnVXV00KLS0tIGN5cWlrdDhGVkVLMlNMNWJVRkEv
|
||||
ejZLR2dsTFlyQTR4amptL2Npb3R3QTAKpP7FdS2HwfBcCjhHolgDV2aEGII0IUwV
|
||||
+V3fy0p1JBrhyGif/d2dca7hJGkMv42TgaGy+EHXZWKw+5cbq/XctQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2021-06-17T11:56:59Z"
|
||||
mac: ENC[AES256_GCM,data:OPUtKdxQNAB564Zljt7zJ6mITLMpf2qmeGvpMsEGi1Y907wMbBCJ5kgoo1t19nr/gEvyY2zE611dcbs5xEqn47WM1L87VJ+YQOfv2dGFg460LrNGaGgqTS7wxyynnAfRmDHVvIowVps4Qso8QVMOIbbiL/Dyn5ePzoQYQlHhp8s=,iv:XN0T1ukTJRWsvhvRsVUUodkFOfyfVrrV0l3OCQSQ95I=,tag:iK2WvfI+33z7T5p7E/7Tag==,type:str]
|
||||
pgp: []
|
||||
encrypted_suffix: secret
|
||||
version: 3.7.1
|
Reference in New Issue
Block a user