I'm trying to build a CI Pipeline with Gitlab CI/CD. My project is a really simple API based on Symfony. To create a consistent environment i'm using docker-compose with four very simple containers (nginx,PHP,MySQL & composer). My .gitlab-ci.yaml looks like this:
stages:
- setup
setup:
stage: setup
before_script:
- docker-compose up -d
script:
- sleep 15
- docker-compose exec -T php php bin/console doctrine:schema:create
after_script:
- [...]
- docker-compose down
The problem I'm encountering is that the ci script does not wait till the docker-compose up -d
is finished. To bypass this I've added this stupid sleep.
Is there a better way to do this?
docker-compose up -d
is finished, but it only tell docker container to start them and works good. Unfortunately this command doesnt know what is inside your containers. That is why you should implement HEALTHCHECK – Datnowdocker-compose logs
, with the--tail
option to limit output size. – Zugzwang