Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • minimize pending time? Buy enterprise account?
  • speed up image building and installation?
  • cache docker image?
  • join base image from the file and ours php7?

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.

like image 962
Eugene Lisitsky Avatar asked Jun 29 '26 11:06

Eugene Lisitsky


1 Answers

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.

like image 191
mohamnag Avatar answered Jul 02 '26 03:07

mohamnag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!