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-mix-context/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/docker-compose-mix-context/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# dagger state
|
||||
state/**
|
89
stdlib/.dagger/env/docker-compose-mix-context/plan/cleanup.cue
vendored
Normal file
89
stdlib/.dagger/env/docker-compose-mix-context/plan/cleanup.cue
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
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
|
||||
if [ -d /source ]; then
|
||||
cd /source
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
46
stdlib/.dagger/env/docker-compose-mix-context/plan/compose.cue
vendored
Normal file
46
stdlib/.dagger/env/docker-compose-mix-context/plan/compose.cue
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/docker"
|
||||
"dagger.io/docker/compose"
|
||||
)
|
||||
|
||||
repo: dagger.#Artifact
|
||||
|
||||
TestCompose: {
|
||||
up: compose.#Up & {
|
||||
ssh: {
|
||||
host: "143.198.64.230"
|
||||
user: "root"
|
||||
}
|
||||
source: repo
|
||||
composeFile: #"""
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
api-mix:
|
||||
build: .
|
||||
environment:
|
||||
PORT: 7000
|
||||
ports:
|
||||
- 7000:7000
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: mix-context
|
||||
"""#
|
||||
}
|
||||
|
||||
verify: docker.#Command & {
|
||||
ssh: up.run.ssh
|
||||
command: #"""
|
||||
docker container ls | grep "api-mix" | grep "Up"
|
||||
"""#
|
||||
}
|
||||
|
||||
cleanup: #CleanupCompose & {
|
||||
context: up.run
|
||||
ssh: verify.ssh
|
||||
}
|
||||
}
|
29
stdlib/.dagger/env/docker-compose-mix-context/values.yaml
vendored
Normal file
29
stdlib/.dagger/env/docker-compose-mix-context/values.yaml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
plan:
|
||||
module: .dagger/env/docker-compose-mix-context/plan
|
||||
name: docker-compose-mix-context
|
||||
inputs:
|
||||
TestCompose.up.ssh.key:
|
||||
secret: ENC[AES256_GCM,data:PFfUg9ViLTNkVbbAUhSk38H3xJwRj2apsxK/pGkHdYbmzSxtwf10R0HcJuRgHY+D/Q8Wy5qNnhByaVePYqpmu28LAMSERcIDqurDX/pDVgyK9dZKCp6Jq+57mVl+PtkyKkYyp/PKWjVI1W6uMSFjjv53OdfUPmygdpcfRiWq2JXRx/SLQtWtfme0QxUPUNVTEnuvmyfA44mZbah6z270rA0/AZyHF1+AKJpY1Dm4y11D1wTamZkAK45EghG0GcUyRjx/PLyIRYzVumcqCUTLMn7frfxjD5ft44C05hL76KJSBEekmsxytj3v7HCvnULEwtsIhcS0imyu139fe9nHPXhTgkJvP2tKZF8P4e65MjHszTema3SUVegCbl5aavms4Z30vRP0kX/sbUVuDktaPMN2bUSBREmbkRBGOKIRHuDDTEgQBRf9eFIMe3Z/kfYjVYRQPiLc+KUhxwXjs43TYebqS+FwzY757h1gvzqdKmtdHK6KI3agmKbgQCmAnvsJEl7C3qlFso8zTgcT0ei2IGHZ86DstMCQFzRU,iv:SgafW/IIOZyyI7uaccDgmERfmiURKX4Z6UGzbRZ5T2s=,tag:XCa3nBhjGch3MjlHRCG4/w==,type:str]
|
||||
repo:
|
||||
dir:
|
||||
path: ./docker/compose/testdata
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
age:
|
||||
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBMSmROdEtUblF3REhwS3hC
|
||||
bU9ObTE0aWQzdGJzRlB5WjA0UG5nZFFJTEJjClljQWFYYWNQaFozZGRMcWxyT3p3
|
||||
Y0ZVUlZISUNlVkxVSVBqY0RRaGxPN3cKLS0tIGhsUTFCK2ljaWZFekVQMlRSRmtD
|
||||
bEY3N3ZLTFpUNzZVWVBOK3VNRk9hWlUKd9db3j7FqFW4t7TxFyzudKDPTVqr66v2
|
||||
KqedhRYCjF4ZozN0H++xQPH24RBRnwc6Uq0Vm38UYv1ozDN2L/l5DA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2021-06-17T13:12:17Z"
|
||||
mac: ENC[AES256_GCM,data:dqszDALkWcBoEZKogzVRGZA/L/5ZUrn872KfcXawx/osd7RZXRNI3DhHN10scX7Mu94yIkFBW0V+TBGseFkA/8uZmgS1AEepVf6Z5GB17/kg7tGiFGJFwNIcc2PqpN+1CvK6SYfo2Ro309wUnt+sCIXEwPn9C5XObaAvje1KnZg=,iv:3Xc75g1OFlp6j+mwWWXfyVPE3gXEnLYGza8FdtQ94zc=,tag:dj4Na2g2KEM2Lz8Ws/op/w==,type:str]
|
||||
pgp: []
|
||||
encrypted_suffix: secret
|
||||
version: 3.7.1
|
Reference in New Issue
Block a user