Eugene Lisitsky
Eugene Lisitsky

Reputation: 12895

GitLab CI speed up

I'm trying to set GitLab CI process and found it very slooooow to start. Task can hang up in pending state for minutes. But main problem is very slow building. We have a custom PHP docker image (with some modules built-in) and app. Deployment to CI can take up to 5-10 minutes.

How is it possible:

Though there're some unnecessary checks for version and time, they're not a problem - they are fast but they give iformation about precise version and run time.

.gitlab-ci.yml:

    image: "registry.gitlab.com/project/debianphp7:latest"

    services:
       - mariadb:10.1

    variables:
    #  CI_DEBUG_TRACE: "true"   # hard Gitlab CI debug
      MYSQL_HOST: mariadb
      MYSQL_DATABASE: dbname
      MYSQL_ROOT_PASSWORD: "password"
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
      MYSQL_CMD: "mysql --user=root --password=$MYSQL_ROOT_PASSWORD --host=$MYSQL_HOST $MYSQL_DATABASE "

    before_script:
      - apt-get update && apt-get install mysql-client -y
      - echo "Load database fixtures"
      - mysql -V
      - echo $MYSQL_CMD
      - echo "SELECT 'OK', NOW(), VERSION();" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb
      - echo "SELECT 'OK', NOW(), VERSION();" | $MYSQL_CMD
      - (find ./sql/*.sql -type f | while read f; do
             echo "Loading " $f;
             cat $f | $MYSQL_CMD;
         done);

    test:
      script:
        php -d short_open_tag=On src/execute_request_by_cron.php -- request=TestUnitTestRequest

Thx.

Upvotes: 3

Views: 2440

Answers (1)

mohamnag
mohamnag

Reputation: 2883

What is not clear to me is if you are using the free hosted version at gitlab.com or a self hosted version of gitlab. But in general you can do following two things:

First the completely free upgrade: All the things that do not change in your code shall best be moved to a pre built image. for example this line:

apt-get update && apt-get install mysql-client -y

I would create an image from your source image that does have the mysql client pre-installed. All the things you need are anyway free, GitHub, Docker Hub and ...

Then assuming you are using gitlab.com, you can either pay for dedicated runners or bring your own by activating private runners.

Upvotes: 2

Related Questions