dprlv04662 2017-07-13 13:15
浏览 185

Gitlab Ci使用docker和mysql服务进行缓慢构建

I´m using gitlab-ci-multirunner 9.3.0 and the GitLab Community Edition 9.3.5

When i´m running my php-unit test on my local virtual box environment, the total test (30) just need about:

Time: 5 minutes, Memory: 96.00MB

Running the same tests on my gitlab host, it needs a total of

Time: 41.68 minutes, Memory: 97.75MB

The tests require mysql and do a database create and fixture load on each test.

My DockerFile:

FROM tetraweb/php:5.6

# Install additional packages
RUN apt-get clean && apt-get -qq update
RUN apt-get -qq upgrade -y
RUN apt-get install -qq -y apt-utils
RUN apt-get install -qq -y mysql-client libmagickwand-dev libgeoip-dev -y --no-install-recommends
RUN pecl install imagick apcu-4.0.11 geoip
RUN docker-php-ext-enable exif gd gettext intl mcrypt mysql mysqli opcache pdo_mysql zip memcache apcu imagick geoi

my gitlab-ci.yml:

variables:
  TIMEZONE: Europe/Berlin
  MYSQL_DATABASE: test
  MYSQL_ROOT_PASSWORD: test-root
  MYSQL_USER: test
  MYSQL_PASSWORD: asecurething
  SYMFONY_ENV: "test"

stages:
  - test
  - deploy

test:
  image: test-image-php:5.6
  services:
    - mariadb:latest
  stage: test
  only:
    - branches
  except:
    - master
  script:
      - export COMPOSER_CACHE_DIR=x/cache/composer
      - SYMFONY_ENV=test composer install --no-progress --no-interaction
      - chmod +x bin/console
      - php vendor/phpunit/phpunit/phpunit --coverage-text --colors=never

I really think thats the mysql service fault who creates the big difference. Whats the best way to increase the performance of my phpunit tests?

  • 写回答

1条回答 默认 最新

  • doudundian9558 2018-01-04 04:01
    关注

    I am using gitlab-ci 10.3.0 where my tests on the server took 40 minutes but on the Mac took 2 minutes. The server outspecs the Mac except for the hard disk where the Mac is using SSD.

    Not sure if appropriate solution but I modified my runner configs to match the one in Docker Executor - Mounting a directory in RAM.

    I have added the following in the config.toml:

    [runners.docker]
    # For the main container
    [runners.docker.tmpfs]
        "/var/lib/mysql" = "rw,noexec"
    
    # For services
    [runners.docker.services_tmpfs]
        "/var/lib/mysql" = "rw,noexec"
    

    I managed to reduce the build time to 2 minutes as well on the server.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c