1

According to the documentation I am trying to add drush in gitlab-ci.yml.

This is the top of my gitlab-ci.yml:

image: tetraweb/php:7.1

services:
  - drush/drush:8

But apparently the service does not start properly:

Running with gitlab-runner 10.8.0 (079aad9e)
  on docker-runner 8a1645e0
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...

*** WARNING: Service runner-8a1645e0-project-35-concurrent-0-drush__drush-0 probably didn't start properly.

Health check error:
exit code 1

Health check container logs:
2019-03-07T16:51:12.703254779Z No HOST or PORT

If I try with the following:

services:
  - name: drush/drush:8
    command: ["drush", "config-import -y"]

I get:

Running with gitlab-runner 10.8.0 (079aad9e)
  on docker-runner e0df35ff
Using Docker executor with image teamdesk/toolbox:7.2 ...
Starting service drush/drush:8 ...
Pulling docker image drush/drush:8 ...
Using docker image sha256:646ef48a637011d5bf97ed3021e280d583aa966e63fceea478d9be8dc5ea2902 for drush/drush:8 ...
Waiting for services to be up and running...

*** WARNING: Service runner-e0df35ff-project-35-concurrent-0-drush__drush-0 probably didn't start properly.

Health check error:
exit code 1

Health check container logs:
2019-03-08T08:37:07.739033180Z No HOST or PORT

Service container logs:
2019-03-08T08:37:07.398595623Z The drush command 'drush config-import -y' could not be found.  Run      [error]
2019-03-08T08:37:07.398686996Z `drush cache-clear drush` to clear the commandfile cache if you have
2019-03-08T08:37:07.398695300Z installed new extensions.

Since I need to run drush updatedb and drush config-import before deploying on the production server, I'd like to use drush as a service in gitlab-ci.yml.

Kwadz
  • 2,206
  • 2
  • 24
  • 45

1 Answers1

1

drush config-import -y is a one-off command ; the process it runs will stop once its job is done. So it is not a service and you cannot put it in the service: section of .gitlab-ci.yml. Gitlab CI Runner expects those services to never stop and will complain if one of the services dies.

what can you do?

run drush in the script: section. For that you must make sure the docker image tetraweb/php:7.1 has the drush command available.

image: tetraweb/php:7.1  ## this image must have drush available

script:
  - drush config-import -y
  - drush updatedb
...
Thomasleveil
  • 95,867
  • 15
  • 119
  • 113
  • I need to run `drush updatedb` and `drush config-import` before deploying on the production server. I updated my question to add details in the logs. – Kwadz Mar 08 '19 at 08:41
  • Thanks, the image does not contain `drush`, that's why I wanted to add it as a service. Would you know if we can use the approach 5 from [this answer](https://stackoverflow.com/a/40855933/1941316)? – Kwadz Mar 08 '19 at 10:16
  • you probably should use https://hub.docker.com/_/drupal as the main docker image, and `mysql` as a Gitlab CI service – Thomasleveil Mar 08 '19 at 10:24
  • The [drupal image](https://hub.docker.com/_/drupal) does not contain `drush` (neither `composer`). I think the only way is to [create a custom Dockerfile](https://stackoverflow.com/a/46271609/1941316). – Kwadz Mar 08 '19 at 11:19