This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/stdlib/docker/compose/tests/compose.cue
Tom Chauveau 020c458921 Add project management in compose.#App definition
I found an issue when during tests execution : there was orphan.
It's because #App doesn't give way to specify the compose project,
by default it's the directory where you launch your app but in our
definition, it will always be source.

The problem is that if we launch two differents docker-compose in the same
server, his project name will be source for both and it will create
orphans problems on cleanup (by docker-compose down).

This case is exactly what we do in tests so I've add the field name
to specify the projet name and avoid that issue.

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
2021-06-26 16:07:14 +02:00

80 lines
1.2 KiB
CUE

package compose
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/docker"
)
repo: dagger.#Artifact @dagger(input)
TestSSH: {
key: dagger.#Secret @dagger(input)
host: string @dagger(input)
user: string @dagger(input)
}
TestCompose: {
name: "compose_test"
up: #App & {
ssh: {
key: TestSSH.key
host: TestSSH.host
user: TestSSH.user
}
source: repo
"name": name
}
verify: docker.#Command & {
ssh: up.run.ssh
command: #"""
docker container ls | grep "\#(name)_api" | grep "Up"
"""#
}
cleanup: #CleanupCompose & {
context: up.run
"name": name
ssh: verify.ssh
}
}
TestInlineCompose: {
name: "inline_test"
up: #App & {
ssh: {
key: TestSSH.key
host: TestSSH.host
user: TestSSH.user
}
source: repo
"name": name
composeFile: #"""
version: "3"
services:
api-mix:
build: .
environment:
PORT: 7000
ports:
- 7000:7000
"""#
}
verify: docker.#Command & {
ssh: up.run.ssh
command: #"""
docker container ls | grep "\#(name)_api-mix" | grep "Up"
"""#
}
cleanup: #CleanupCompose & {
context: up.run
"name": name
ssh: verify.ssh
}
}