Skip to content

Docker images for build and test PHP applications with Gitlab CI Pipeline (or any other CI plataform!)

Notifications You must be signed in to change notification settings

carspending/gitlab-ci-pipeline-php

 
 

Repository files navigation

Build and test PHP applications with Gitlab CI

Docker images with everything you'll need to build and test PHP applications on Gitlab Continous Integration (or any other CI plataform!)

Logo


All versions come with Node 9, Composer and Yarn

Docker Pulls


Laravel users

These images come with PHP (with all laravel required extensions), Composer (with hirak/prestissimo to speed up), Node and Yarn.

Everything you need to test Laravel projects :D


Gitlab pipeline examples

Laravel test examples

Simple .gitlab-ci.yml using mysql service

# Variables
variables:
  MYSQL_ROOT_PASSWORD: root
  MYSQL_USER: homestead
  MYSQL_PASSWORD: secret
  MYSQL_DATABASE: homestead
  DB_HOST: mysql

test:
  stage: test
  services:
    - mysql:5.7
  image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
  script:
    - yarn
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
    - cp .env.example .env
    - php artisan key:generate
    - php artisan migrate:refresh --seed
    - ./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors=never --stderr

Advanced .gitlab-ci.yml using mysql service, stages and cache

stages:
  - test
  - deploy

# Variables
variables:
  MYSQL_ROOT_PASSWORD: root
  MYSQL_USER: homestead
  MYSQL_PASSWORD: secret
  MYSQL_DATABASE: homestead
  DB_HOST: mysql

# Speed up builds
cache:
  key: $CI_BUILD_REF_NAME # changed to $CI_COMMIT_REF_NAME in Gitlab 9.x
  paths:
    - vendor
    - node_modules
    - public
    - .yarn


test:
  stage: test
  services:
    - mysql:5.7
  image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
  script:
    - sudo yarn config set cache-folder .yarn
    - yarn install --pure-lockfile
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
    - cp .env.example .env
    - php artisan key:generate
    - php artisan migrate:refresh --seed
    - ./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors=never --stderr
  artifacts:
    paths:
      - ./storage/logs # for debugging
    expire_in: 1 days
    when: always

deploy:
  stage: deploy
  image: edbizarro/gitlab-ci-pipeline-php:7.1
  script:
    - echo "Deploy all the things!"
  only:
    - master
  when: on_success

Deploying Laravel applications with Gitlab

Recommended


Special thanks to Ambientum, an incredible Brazilian project, for the inspiration.

Also https://github.com/Chialab/docker-php for php 7.2 build scripts

forthebadge forthebadge

About

Docker images for build and test PHP applications with Gitlab CI Pipeline (or any other CI plataform!)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%