Skip to content

Instantly share code, notes, and snippets.

@iolson
Created September 17, 2015 22:14
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save iolson/2c6941c9780b1ebcc25f to your computer and use it in GitHub Desktop.
Save iolson/2c6941c9780b1ebcc25f to your computer and use it in GitHub Desktop.
GitLab CI Laravel 5.1.*
DB_HOST=mysql
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
# Before Script
before_script:
- composer self-update
- composer install --prefer-dist > /dev/null
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:refresh --seed
# Services
services:
- mysql:latest
# Variables
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_DATABASE: homestead
# PHP 5.5
php:5.5:
image: bobey/docker-gitlab-ci-runner-php5.5
script:
- echo "Running PHPUnit Tests"
- php vendor/bin/phpunit --colors --debug --coverage-text
# PHP 5.6
php:5.6:
image: bobey/docker-gitlab-ci-runner-php5.6
script:
- echo "Running PHPUnit Tests"
- php vendor/bin/phpunit --colors --debug --coverage-text
> php artisan clear-compiled
> php artisan optimize
$ cp .env.example .env
$ php artisan key:generate
Application key [Dg4rH8UrV4klq49ORLJrXGbe84Y96XTf] set successfully.
$ php artisan migrate:refresh --seed
[PDOException]
SQLSTATE[HY000] [2002] No route to host
ERROR: Build failed with: exit code 1
[runners]]
name = "php"
url = "<domain name removed>"
token = "<token removed>"
limit = 1
executor = "docker"
environment = ["MYSQL_ALLOW_EMPTY_PASSWORD=1"]
[runners.docker]
allowed_images = ["*", "*/*"]
allowed_services = ["*", "*/*"]
privileged = false
volumes = ["/cache", "/composer-auth.json:/root/.composer/auth.json:ro"]
wait_for_services_timeout = 0
@xar
Copy link

xar commented Feb 6, 2016

http://doc.gitlab.com/ce/ci/services/mysql.html you need to use mysql as hostname

@devnix
Copy link

devnix commented Feb 26, 2016

In config.toml

[runners]]

Typo?

@shankargiri
Copy link

I used the above .yml file but still have an issue with database migration during the build with GitLab. Anyone, if have any idea please throw some inputs here.

WARNING: Service mysql:latest is already created. Ignoring.
Waiting for services to be up and running...

*** WARNING: Service runner-8c63a854-project-962504-concurrent-0-mysql probably didn't start properly.

didn't respond in timely maner: runner-8c63a854-project-962504-concurrent-0-mysql (consider modifying wait_for_services_timeout: 30s).

2016-03-13T15:56:34.933385100Z Initializing database


[PDOException]                                    
  SQLSTATE[HY000] [2002] No such file or directory  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment