Summary
The user is looking for a method to replicate the Docker Compose --wait
flag functionality in Earthly for running integration tests, aiming to ensure all services are healthy before continuing. They mention that the current Earthly integration test guide suggests health checks are done "out-of-bands," which they find more complex than Docker Compose. They inquire if the depends-on
field in the Docker Compose YAML could assist and note that manual health checks, such as pinging a port, have been used in Earthfiles.
aurelien.deroide
While it would work, in my opinion that requires even more code and toll to create and use such image than the other alternatives
brandon
Yeah I agree that would be cleaner.. Another thought, what if your go test
was containerized and part of your docker-compose stack? That way it could use depends-on
to make sure DB is up etc
aurelien.deroide
But it'd be way cleaner if I could just do
FROM +src
COPY docker-compose.integtest.yaml .
WITH DOCKER --compose docker-compose.integtest.yaml --wait
RUN go test ./integration-test
END```
aurelien.deroide
And then my workaround Earthfile is
FROM +src
COPY docker-compose.integtest.yaml .
WITH DOCKER --compose docker-compose.integtest.yaml
RUN docker compose -f docker-compose.integtest.yaml up -d --wait mysql && go test ./integration-test
END```
aurelien.deroide
I don't think I can leverage depends-on
here, because I don't have a docker-compose service that depends on the db
My dockerfile is simply
mysql:
image: mariadb:10.9
environment:
MYSQL_DATABASE: ${SQL_DATABASE:-cloud}
MYSQL_USER: ${SQL_USER:-cloud}
MYSQL_PASSWORD: ${SQL_PASSWORD:-cloud}
MYSQL_PWD: ${SQL_PASSWORD:-cloud}
MARIADB_ROOT_PASSWORD: root
ports:
- 3306:3306
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 5s
timeout: 3s
retries: 2
start_period: 0s```
brandon
Would the depends-on
field in the docker compose yaml help? I’ve seen manual health-checks done in Earthfiles before too, e.g. pinging a port to make sure the service is up before proceeding with the integration test
aurelien.deroide
Hello !
I'm trying to run integration test via earthly and I'm wondering if there's a way to get the same behavior as docker compose --wait
flag with wait for all services to be healthy before continuing
The integration test https://docs.earthly.dev/docs/guides/integration#in-app-integration-testing|guide show that the healthcheck is done "out-of-bands" before running the tests, but it's more complicate to implement than just delegating this to docker compose.