├── README.md ├── base ├── Dockerfile └── files │ └── run ├── nodejs └── Dockerfile └── php ├── 5.4 ├── Dockerfile └── files │ └── ci-runner.ini ├── 5.5 ├── Dockerfile └── files │ └── ci-runner.ini ├── 5.6 ├── Dockerfile └── files │ └── ci-runner.ini ├── 7.0 ├── Dockerfile └── files │ └── ci-runner.ini └── base ├── Dockerfile └── files └── configure /README.md: -------------------------------------------------------------------------------- 1 | # Docker GitlabCI Runner images 2 | 3 | Gitlab CI runner docker base images with ssh-key sharing. 4 | 5 | Take care, this project is not maintained anymore and **deprecated** in favor of official [Gitlab Multi-Runner](https://gitlab.com/gitlab-org/gitlab-ci-multi-runner) 6 | 7 | ## Table of contents 8 | 9 | - [Base Image](#base-image) 10 | - [Build](#build) 11 | - [Usage](#usage) 12 | - [PHP Images](#php-images) 13 | - [Usage](#usage-1) 14 | - [Custom PHP configuration](#custom-php-configuration) 15 | - [Development](#development) 16 | - [NodeJS Image](#nodejs-image) 17 | - [Usage](#usage-2) 18 | - [Development](#development-1) 19 | - [Gitlab CI setup](#gitlab-ci-setup) 20 | - [Contributors](#contributors) 21 | 22 | ## Base Image 23 | 24 | This docker image is based on [gitlabhq/gitlab-ci-runner](https://github.com/gitlabhq/gitlab-ci-runner) image and provide a way to pass it an ssh-key or automatically 25 | generate a new one. 26 | This is a base image you can extend with your own stack. 27 | 28 | ### Build 29 | 30 | In order to build it, you need to execute the following commands: 31 | 32 | ``` 33 | docker build -t gitlabhq/gitlab-ci-runner github.com/gitlabhq/gitlab-ci-runner 34 | docker build -t bobey/docker-gitlab-ci-runner github.com/bobey/docker-gitlab-ci-runner 35 | ``` 36 | 37 | ### Usage 38 | 39 | ``` 40 | docker pull bobey/docker-gitlab-ci-runner 41 | ``` 42 | 43 | Then, you can run as many runners as you want by executing: 44 | 45 | ``` 46 | docker run \ 47 | -e CI_SERVER_URL=https://ci.example.com \ 48 | -e REGISTRATION_TOKEN=replaceme \ 49 | -e HOME=/root \ 50 | -e GITLAB_SERVER_FQDN=gitlab.example.com \ 51 | bobey/docker-gitlab-ci-runner 52 | ``` 53 | 54 | If you need to pass an ssh key to the runner (a deploy key for example), use the following command: 55 | 56 | ``` 57 | docker run \ 58 | -e CI_SERVER_URL=https://ci.example.com \ 59 | -e REGISTRATION_TOKEN=replaceme \ 60 | -e HOME=/root \ 61 | -e GITLAB_SERVER_FQDN=gitlab.example.com \ 62 | -v /absolute/path/to/your/home/.ssh/id_rsa:/root/.ssh/id_rsa:ro \ 63 | bobey/docker-gitlab-ci-runner 64 | ``` 65 | 66 | If you don't mount this optional volume, an ssh-key will be automatically generated and the public key will be displayed 67 | on standard output. 68 | 69 | If you need to start a bash inside your container, use the following command: 70 | 71 | ``` 72 | docker run \ 73 | -e CI_SERVER_URL=https://ci.example.com \ 74 | -e REGISTRATION_TOKEN=replaceme \ 75 | -e HOME=/root --rm -it \ 76 | bobey/docker-gitlab-ci-runner:latest /bin/bash 77 | ``` 78 | 79 | ## PHP Images 80 | 81 | We provide docker gitlab-ci runner images for php 5.4, 5.5 and 5.6 containing the following stack: 82 | 83 | - PHP 5.x 84 | - Git 85 | - Composer 86 | 87 | ### Usage 88 | 89 | You can run as many runners as you want by executing: 90 | 91 | ``` 92 | docker run \ 93 | -e CI_SERVER_URL=https://ci.example.com \ 94 | -e REGISTRATION_TOKEN=replaceme \ 95 | -e HOME=/root \ 96 | -e GITLAB_SERVER_FQDN=gitlab.example.com \ 97 | -v /absolute/path/to/your/home/.ssh/id_rsa:/root/.ssh/id_rsa:ro \ 98 | bobey/docker-gitlab-ci-runner-php5.6 99 | ``` 100 | 101 | In your GitlabCI, a basic phpunit job could looks like this: 102 | 103 | ``` 104 | composer install 105 | php vendor/phpunit/phpunit/phpunit --coverage-text 106 | ``` 107 | 108 | By displaying code coverage as text, you can easily extract code coverage metrics. In your project settings, under 109 | "Test coverage parsing", just input the following regex: ` Lines:\s+(\d+.\d+\%)`. 110 | 111 | ### Custom PHP configuration 112 | 113 | All PHP images comes with the following extensions pre-installed but not enabled by default with the exception of 114 | `xdebug`: 115 | 116 | - memcache.so 117 | - mongo.so 118 | - redis.so 119 | - ssh2.so 120 | - xdebug.so 121 | 122 | If you need to customize the php configuration, you can add your own settings to the `ci-runner.ini` file. 123 | For example, the following command in one of your gitlab-ci jobs will enable `mongo.so` extension: 124 | 125 | ``` 126 | echo 'extension="mongo.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/ci-runner.ini 127 | ``` 128 | 129 | You can of course customize any other parameter of the `php.ini` configuration file. Below command will set `Europe/Paris` as the default timezone: 130 | 131 | ``` 132 | echo 'date.timezone="Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/ci-runner.ini 133 | ``` 134 | 135 | ### Composer and Github API rate limit 136 | 137 | All PHP images comes with Composer pre-installed and ready to be used. But, as you might already know, Github API rate limit is quite often reached when building projects in CI. See what [Composer doc say about it](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens). 138 | 139 | One way to handle this problem is to create an `auth.json` file and share it with your gitlab-ci-runners via a volume: 140 | 141 | ```json 142 | { 143 | "http-basic": {}, 144 | "github-oauth": { 145 | "github.com": "GITHUB_GENERATED_TOKEN" 146 | } 147 | } 148 | ``` 149 | 150 | Then, start your runner with an extra `-v` option: 151 | 152 | ``` 153 | docker run \ 154 | -e ... 155 | -v /absolute/path/to/composer-auth.json:/root/.composer/auth.json:ro \ 156 | bobey/docker-gitlab-ci-runner-php5.6 157 | ``` 158 | 159 | ### Development 160 | 161 | This docker image is based on bobey/docker-gitlab-ci-runner image. In order to build it, you need to execute the following 162 | command: 163 | 164 | ``` 165 | docker build -t bobey/docker-gitlab-ci-runner-php5.6 github.com/bobey/docker-gitlab-ci-runner/php/5.6 166 | ``` 167 | 168 | ## NodeJS Image 169 | 170 | A docker gitlab-ci runner containing the following stack: 171 | 172 | - NodeJS 173 | - NPM 174 | 175 | ### Usage 176 | 177 | You can run as many runners as you want by executing: 178 | 179 | ``` 180 | docker run \ 181 | -e CI_SERVER_URL=https://ci.example.com \ 182 | -e REGISTRATION_TOKEN=replaceme \ 183 | -e HOME=/root \ 184 | -e GITLAB_SERVER_FQDN=gitlab.example.com \ 185 | -v /absolute/path/to/your/home/.ssh/id_rsa:/root/.ssh/id_rsa:ro \ 186 | bobey/docker-gitlab-ci-runner-nodejs 187 | ``` 188 | 189 | ### Development 190 | 191 | This docker image is based on bobey/docker-gitlab-ci-runner image. In order to build it, you need to execute the following 192 | commands: 193 | 194 | ``` 195 | docker build -t bobey/docker-gitlab-ci-runner-php github.com/bobey/docker-gitlab-ci-runner/nodejs 196 | ``` 197 | 198 | ## Gitlab CI setup 199 | 200 | By starting Gitlab CI runners through Docker, assuming you passed a valid registration token, they will automatically 201 | add themselves to your CI instance. You should see them in the "Runners" tab. 202 | 203 | ## Contributors 204 | 205 | Many thanks to the awesome [@jubianchi](https://twitter.com/jubianchi) for its help with the base php image. 206 | -------------------------------------------------------------------------------- /base/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner 2 | 3 | FROM gitlabhq/gitlab-ci-runner 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ADD files/run /sbin/run 7 | RUN chmod +x /sbin/run 8 | 9 | VOLUME /root/.ssh 10 | 11 | CMD "/sbin/run" 12 | -------------------------------------------------------------------------------- /base/files/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! -f ~/.ssh/id_dsa && ! -f ~/.ssh/id_rsa ]] 4 | then 5 | echo -e "\033[32mCreating new public key\033[0m" 6 | ssh-keygen -q -N '' -f ~/.ssh/id_rsa >/dev/null 2>&1 7 | 8 | echo -e "\033[32mPublic key at $(readlink -f ~/.ssh/id_rsa.pub)\033[0m" 9 | cat ~/.ssh/id_rsa.pub 10 | fi 11 | 12 | chmod -R 600 ~/.ssh 13 | 14 | ssh-keyscan -H $GITLAB_SERVER_FQDN >> /root/.ssh/known_hosts 15 | bundle exec ./bin/setup_and_run 16 | -------------------------------------------------------------------------------- /nodejs/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-nodejs 2 | 3 | FROM bobey/docker-gitlab-ci-runner 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | RUN apt-get update && apt-get install -y software-properties-common && \ 7 | add-apt-repository -y ppa:chris-lea/node.js && \ 8 | apt-get update && \ 9 | apt-get install -y nodejs 10 | -------------------------------------------------------------------------------- /php/5.4/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-php5.4 2 | 3 | FROM bobey/docker-gitlab-ci-runner-php 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ENV PHP_VERSION 5.4.38 7 | 8 | COPY files/ci-runner.ini /root/.phpenv/versions/$PHP_VERSION/etc/conf.d/ci-runner.ini 9 | 10 | RUN phpenv install $PHP_VERSION \ 11 | phpenv rehash && \ 12 | phpenv global $PHP_VERSION 13 | 14 | # Install PHP PECL extensions 15 | RUN yes '' | pecl install \ 16 | mongo \ 17 | redis \ 18 | memcache \ 19 | ssh2-0.12 \ 20 | xdebug 21 | -------------------------------------------------------------------------------- /php/5.4/files/ci-runner.ini: -------------------------------------------------------------------------------- 1 | ;gitlab-ci-runner image specific php.ini config 2 | date.timezone = "UTC" 3 | -------------------------------------------------------------------------------- /php/5.5/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-php5.5 2 | 3 | FROM bobey/docker-gitlab-ci-runner-php 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ENV PHP_VERSION 5.5.22 7 | 8 | COPY files/ci-runner.ini /root/.phpenv/versions/$PHP_VERSION/etc/conf.d/ci-runner.ini 9 | 10 | RUN phpenv install $PHP_VERSION \ 11 | phpenv rehash && \ 12 | phpenv global $PHP_VERSION 13 | 14 | # Install PHP PECL extensions 15 | RUN yes '' | pecl install \ 16 | mongo \ 17 | redis \ 18 | memcache \ 19 | ssh2-0.12 \ 20 | xdebug 21 | -------------------------------------------------------------------------------- /php/5.5/files/ci-runner.ini: -------------------------------------------------------------------------------- 1 | ;gitlab-ci-runner image specific php.ini config 2 | date.timezone = "UTC" 3 | -------------------------------------------------------------------------------- /php/5.6/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-php5.6 2 | 3 | FROM bobey/docker-gitlab-ci-runner-php 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ENV PHP_VERSION 5.6.6 7 | 8 | COPY files/ci-runner.ini /root/.phpenv/versions/$PHP_VERSION/etc/conf.d/ci-runner.ini 9 | 10 | RUN phpenv install $PHP_VERSION \ 11 | phpenv rehash && \ 12 | phpenv global $PHP_VERSION 13 | 14 | # Install PHP PECL extensions 15 | RUN yes '' | pecl install \ 16 | mongo \ 17 | redis \ 18 | memcache \ 19 | ssh2-0.12 \ 20 | xdebug 21 | -------------------------------------------------------------------------------- /php/5.6/files/ci-runner.ini: -------------------------------------------------------------------------------- 1 | ;gitlab-ci-runner image specific php.ini config 2 | date.timezone = "UTC" 3 | -------------------------------------------------------------------------------- /php/7.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-php7 2 | 3 | FROM bobey/docker-gitlab-ci-runner-php 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ENV PHP_VERSION 7.0.4 7 | 8 | COPY files/ci-runner.ini /root/.phpenv/versions/$PHP_VERSION/etc/conf.d/ci-runner.ini 9 | 10 | RUN phpenv install $PHP_VERSION \ 11 | phpenv rehash && \ 12 | phpenv global $PHP_VERSION 13 | 14 | RUN DEBIAN_FRONTEND=noninteractive apt-get remove -y --purge php* 15 | 16 | RUN DEBIAN_FRONTEND=noninteractive apt-get update 17 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-software-properties 18 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common 19 | RUN DEBIAN_FRONTEND=noninteractive LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php 20 | 21 | RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ 22 | php7.0-cli \ 23 | php7.0-common \ 24 | php7.0-dev \ 25 | php7.0-json \ 26 | php7.0-opcache \ 27 | php7.0-mysql \ 28 | php7.0-phpdbg \ 29 | php7.0-mbstring \ 30 | php7.0-gd \ 31 | php7.0-imap \ 32 | php7.0-ldap \ 33 | php7.0-pgsql \ 34 | php7.0-sqlite \ 35 | php7.0-pdo \ 36 | php7.0-pspell \ 37 | php7.0-recode \ 38 | php7.0-tidy \ 39 | php7.0-intl \ 40 | php7.0-curl \ 41 | php7.0-zip \ 42 | php7.0-xml \ 43 | php-mongodb \ 44 | php-redis \ 45 | php-memcache \ 46 | php-xdebug -------------------------------------------------------------------------------- /php/7.0/files/ci-runner.ini: -------------------------------------------------------------------------------- 1 | ;gitlab-ci-runner image specific php.ini config 2 | date.timezone = "UTC" 3 | 4 | ;enable xdebug by default 5 | zend_extension = /usr/lib/php/20151012/xdebug.so 6 | -------------------------------------------------------------------------------- /php/base/Dockerfile: -------------------------------------------------------------------------------- 1 | # docker-gitlab-ci-runner-php 2 | 3 | FROM bobey/docker-gitlab-ci-runner 4 | MAINTAINER Olivier Balais "obalais@gmail.com" 5 | 6 | ENV PHP_DIR /etc/php5 7 | ENV PATH /root/.phpenv/bin:/root/.phpenv/shims:$PATH 8 | 9 | # Install packages required to build PHP 10 | RUN apt-get update -y && \ 11 | apt-get build-dep -y php5 && \ 12 | apt-get install -y libmcrypt-dev libltdl-dev libreadline-dev libc-client2007e-dev libbz2-dev libkrb5-dev \ 13 | libcurl4-gnutls-dev libfreetype6-dev libgmp-dev libjpeg8-dev libpng12-dev libt1-dev \ 14 | libmhash-dev libexpat1-dev libicu-dev libtidy-dev re2c lemon libldap2-dev libsasl2-dev \ 15 | libssh2-1-dev 16 | 17 | # Install some usefull packages 18 | RUN apt-get update -y && \ 19 | apt-get install -y git \ 20 | wget \ 21 | curl \ 22 | apache2 \ 23 | php-pear 24 | 25 | # Install a specific bison version 26 | RUN wget -O /tmp/libbison-dev.deb http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb && \ 27 | wget -O /tmp/bison_2.7.1.deb http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb && \ 28 | dpkg -i /tmp/libbison-dev.deb && \ 29 | dpkg -i /tmp/bison_2.7.1.deb && \ 30 | rm -f /tmp/*.deb 31 | 32 | RUN git clone https://github.com/CHH/phpenv.git /tmp/phpenv && \ 33 | /tmp/phpenv/bin/phpenv-install.sh && \ 34 | sudo /bin/bash -c "echo 'eval \"\$(phpenv init -)\"' >> /etc/profile.d/phpenv.sh" && \ 35 | echo 'eval "$(phpenv init -)"' >> /root/.bashrc 36 | 37 | RUN git clone git://github.com/CHH/php-build.git /root/.phpenv/plugins/php-build 38 | COPY files/configure /root/.phpenv/plugins/php-build/share/php-build/default_configure_options 39 | 40 | RUN ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/libfreetype.so && \ 41 | ln -s /usr/lib/x86_64-linux-gnu/libgmp.so /usr/lib/libgmp.so && \ 42 | ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so && \ 43 | ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h 44 | 45 | # Install composer 46 | RUN curl -sS https://getcomposer.org/installer | php && \ 47 | mv composer.phar /usr/local/bin/composer 48 | -------------------------------------------------------------------------------- /php/base/files/configure: -------------------------------------------------------------------------------- 1 | --enable-intl 2 | --enable-exif 3 | --enable-zip 4 | --enable-soap 5 | --enable-xmlreader 6 | --enable-ftp 7 | --enable-sysvsem 8 | --enable-sysvshm 9 | --enable-sysvmsg 10 | --enable-shmop 11 | --enable-pcntl 12 | --enable-mbstring 13 | --enable-fpm 14 | --enable-bcmath 15 | --enable-calendar 16 | --enable-sockets 17 | 18 | --with-mysql=mysqlnd 19 | --with-mysqli=mysqlnd 20 | --with-pdo-mysql=mysqlnd 21 | --with-libdir=lib 22 | --with-ldap=shared 23 | --with-jpeg-dir=/usr 24 | --with-png-dir=/usr 25 | --with-freetype-dir=/usr 26 | --with-zlib-dir=/usr 27 | --with-mcrypt=/usr 28 | --with-freetype-dir=/usr 29 | 30 | --with-zlib 31 | --with-pdo-sqlite 32 | --with-openssl 33 | --without-pear 34 | --with-gd 35 | --with-readline 36 | --with-curl 37 | --with-pgsql 38 | --with-pdo-pgsql 39 | --with-gettext 40 | --with-xsl 41 | --with-tidy 42 | --with-xmlrpc 43 | --with-bz2 44 | --with-gmp 45 | --with-kerberos 46 | --with-imap 47 | --with-imap-ssl 48 | --with-ldap-sasl 49 | --with-ssh2 50 | --------------------------------------------------------------------------------