Public | Automated Build

Last pushed: 2 years ago
Short Description
A CakePHP 3.x Docker Container for use with Gitlab CI and general development of CakePHP 3.x apps
Full Description

GitlabCakePHP3

A docker container designed for use as a a test runner for CakePHP 3.x applications

Gitlab CI

If you want to use this with Gitlab CI all you need to do is add a .gitlab.yml file to the root of your Gitlab project pulling this container and then specify your test database in the config/app.php file.

Example .gitlab.yml

image: kaffineaddict/gitlabcakephp3

# Cache the vendor folder
cache:
  paths:
  - vendor/


before_script:
# Install git to clone your repository
- apt-get update -yqq
- apt-get install git -yqq

# Install composer
- curl -sS https://getcomposer.org/installer | php

# Install all project dependencies
- composer install

services:
- mysql

variables:
  # Configure mysql service (https://hub.docker.com/_/mysql/)
  # We will need to use these in the app.php test datasource
  MYSQL_DATABASE: cake_test
  MYSQL_ROOT_PASSWORD: mysql

# Run the phpunit tests
All:
 script:
  - vendor/bin/phpunit

Example config/app.php

Make sure to put the settings under the 'test' entry. You can see that we use the root username with the password defined above and the database defined above.

    'test' => [
        'className' => 'Cake\Database\Connection',
        'driver' => 'Cake\Database\Driver\Mysql',
        'persistent' => false,
        'host' => 'mysql',
        //'port' => 'nonstandard_port_number',
        'username' => 'root',
        'password' => 'mysql',
        'database' => 'cake_test',
        'encoding' => 'utf8',
        'timezone' => 'UTC',
        'cacheMetadata' => true,
        'quoteIdentifiers' => false,
        'log' => false,
    ],
],
Docker Pull Command
Owner
kaffineaddict
Source Repository