Skip to content

cstadler333/gitlab-ci-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.

Logo


GitHub last commit

Docker Pulls


CURRENTLY ONLY ALPINE IMAGES!

All versions come with:


Gitlab pipeline examples

Symfony examples

Simple .gitlab-ci.yml using MariaDB service

variables:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_USER: symfony
    MYSQL_PASSWORD: password
    MYSQL_DATABASE: project
    APP_ENV: prod
    DATABASE_URL: mysql://$MYSQL_USER:$MYSQL_PASSWORD@mysql/$MYSQL_DATABASE

image: cstadler333/gitlab-ci-php:8.3-alpine
services:
    - mariadb:10.11

build:
    stage: build
    before_script:
        - npm install
    script:
        - npm run build
        - composer install --prefer-dist --no-ansi --no-interaction --no-progress

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

stages:
    - build
    - deploy

variables:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_USER: symfony
    MYSQL_PASSWORD: password
    MYSQL_DATABASE: project
    APP_ENV: prod
    DATABASE_URL: mysql://$MYSQL_USER:$MYSQL_PASSWORD@mysql/$MYSQL_DATABASE

cache:
    key: $CI_COMMIT_REF_NAME
    paths:
        - node_modules/
        - vendor/

image: cstadler333/gitlab-ci-php:8.3-alpine
services:
    - mariadb:10.11

.build_template: &build
    stage: build
    before_script:
        - npm install --force
    script:
        - npm run build
        - composer install --prefer-dist --no-ansi --no-interaction --no-progress

.deploy_template: &deploy
    stage: deploy
    before_script:
        - 'which ssh-agent || ( apt-get install -qq openssh-client )'
        - eval $(ssh-agent -s)
        - ssh-add <(echo "$SSH_PRIVATE_KEY")
        - mkdir -p ~/.ssh
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

Build Master:
    <<: *build
    only:
        - master

Deploy Master:
    <<: *deploy
    only:
        - master
    script:
        - rsync -a --progress --human-readable --delete
            --exclude .git
            --exclude node_modules
            --exclude var
            --exclude vendor
            .
            user@server:path

Deploying PHP applications with Gitlab

Recommended