.gitlab-ci.yml - wordpress service wait for db

Viewed 532

I want to do some automatic testing with WordPress in GitLab CI.

test:
  image: alpine
  stage: test
  tags:
    - docker
  services:
    - alias: db
      name: mysql:5.7
    - alias: wp
      name: wordpress:4.7-apache
  variables:
    WORDPRESS_DB_HOST: db
    WORDPRESS_DB_USER: exampleuser
    WORDPRESS_DB_PASSWORD: examplepass
    WORDPRESS_DB_NAME: exampledb
    MYSQL_DATABASE: exampledb
    MYSQL_USER: exampleuser
    MYSQL_PASSWORD: examplepass
    MYSQL_RANDOM_ROOT_PASSWORD: '1'
  script:
    - echo "hi"

At the moment it doesnt work, because the WP container directly starts setup, while the DB still is setting up.

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22

Can I add some delay somehow? GitLab doesn't offer that and also there is no environment variable the WP container, right?

Update 2021-03-29: GitLab issue created: https://gitlab.com/gitlab-org/gitlab/-/issues/326199

1 Answers
Related