|
|
@ -1,81 +1,93 @@
|
|
|
|
image: php
|
|
|
|
image: php
|
|
|
|
|
|
|
|
|
|
|
|
cache:
|
|
|
|
|
|
|
|
paths:
|
|
|
|
|
|
|
|
- .composer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
- mariadb:10.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
variables:
|
|
|
|
variables:
|
|
|
|
|
|
|
|
DOCKER_DRIVER: overlay2
|
|
|
|
|
|
|
|
TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
|
|
|
|
|
|
|
RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
|
|
|
MYSQL_DATABASE: engelsystem
|
|
|
|
MYSQL_DATABASE: engelsystem
|
|
|
|
MYSQL_USER: engel
|
|
|
|
MYSQL_USER: engel
|
|
|
|
MYSQL_PASSWORD: engelsystem
|
|
|
|
MYSQL_PASSWORD: engelsystem
|
|
|
|
MYSQL_HOST: mariadb
|
|
|
|
MYSQL_HOST: mariadb
|
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
|
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
|
|
|
|
COMPOSER_HOME: .composer
|
|
|
|
DOCROOT: /var/www/
|
|
|
|
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
stages:
|
|
|
|
# Fix permissions after gitlab messed them up
|
|
|
|
- build
|
|
|
|
- &before_fix_permissions |-
|
|
|
|
- test
|
|
|
|
find . -type f -exec chmod 644 {} \;
|
|
|
|
- release
|
|
|
|
find . -type d -exec chmod 755 {} \;
|
|
|
|
- deploy
|
|
|
|
# Install required Packages
|
|
|
|
|
|
|
|
- &before_install_packages |-
|
|
|
|
|
|
|
|
apt update -yqq
|
|
|
|
|
|
|
|
apt install -yqq git unzip
|
|
|
|
|
|
|
|
docker-php-ext-install pdo pdo_mysql gettext
|
|
|
|
|
|
|
|
# Install xdebug
|
|
|
|
|
|
|
|
- &before_install_xdebug |-
|
|
|
|
|
|
|
|
pecl install xdebug
|
|
|
|
|
|
|
|
docker-php-ext-enable xdebug
|
|
|
|
|
|
|
|
# MySQL DB
|
|
|
|
|
|
|
|
- &before_setup_mysql |-
|
|
|
|
|
|
|
|
apt install -yqq mariadb-client
|
|
|
|
|
|
|
|
mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/install.sql
|
|
|
|
|
|
|
|
mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/update.sql
|
|
|
|
|
|
|
|
# Install Composer
|
|
|
|
|
|
|
|
- &before_install_composer |-
|
|
|
|
|
|
|
|
curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
|
|
|
|
|
|
|
|
composer --no-ansi install
|
|
|
|
|
|
|
|
# Install Node.js and Yarn
|
|
|
|
|
|
|
|
- &before_install_yarn |-
|
|
|
|
|
|
|
|
apt -yqq install gnupg2 apt-transport-https
|
|
|
|
|
|
|
|
curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
|
|
|
|
|
|
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
|
|
|
|
|
|
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
|
|
|
|
|
|
|
|
apt -yqq update && apt -yqq install nodejs yarn
|
|
|
|
|
|
|
|
yarn install
|
|
|
|
|
|
|
|
yarn build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.test_template: &test_definition
|
|
|
|
.docker_template: &docker_definition
|
|
|
|
|
|
|
|
image: docker:latest
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
- docker:dind
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- dind
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
|
|
|
|
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build-image:
|
|
|
|
|
|
|
|
<<: *docker_definition
|
|
|
|
|
|
|
|
stage: build
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
|
|
|
- docker build --pull -t "$TEST_IMAGE" -f contrib/Dockerfile .
|
|
|
|
|
|
|
|
- docker push "$TEST_IMAGE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build-image.nginx:
|
|
|
|
|
|
|
|
<<: *docker_definition
|
|
|
|
|
|
|
|
stage: build
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
|
|
|
- docker build --pull -t "$TEST_IMAGE.nginx" -f contrib/nginx/Dockerfile .
|
|
|
|
|
|
|
|
- docker push "$TEST_IMAGE.nginx"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
|
|
|
image: $TEST_IMAGE
|
|
|
|
stage: test
|
|
|
|
stage: test
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
|
|
- mariadb:10.2
|
|
|
|
artifacts:
|
|
|
|
artifacts:
|
|
|
|
name: "${CI_JOB_NAME}_${CI_JOB_ID}"
|
|
|
|
name: "${CI_JOB_NAME}_${CI_JOB_ID}"
|
|
|
|
expire_in: 1 week
|
|
|
|
expire_in: 1 week
|
|
|
|
paths:
|
|
|
|
paths:
|
|
|
|
- ./coverage/
|
|
|
|
- ./coverage/
|
|
|
|
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
|
|
|
|
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
|
|
|
|
script: vendor/bin/phpunit --colors=never --coverage-text --coverage-html ./coverage/
|
|
|
|
before_script:
|
|
|
|
|
|
|
|
- apk add $PHPIZE_DEPS && pecl install xdebug && docker-php-ext-enable xdebug
|
|
|
|
|
|
|
|
- apk add mariadb-client
|
|
|
|
|
|
|
|
- mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/install.sql
|
|
|
|
|
|
|
|
- mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/update.sql
|
|
|
|
|
|
|
|
- curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
|
|
|
|
|
|
|
|
- cp -R tests/ phpunit.xml "${DOCROOT}"
|
|
|
|
|
|
|
|
- HOMEDIR=$(pwd)
|
|
|
|
|
|
|
|
- cd "${DOCROOT}"
|
|
|
|
|
|
|
|
- composer --no-ansi install --dev
|
|
|
|
|
|
|
|
script: vendor/bin/phpunit -v --colors=never --coverage-text --coverage-html "${HOMEDIR}/coverage/"
|
|
|
|
|
|
|
|
|
|
|
|
test:7.0:
|
|
|
|
release-image:
|
|
|
|
<<: *test_definition
|
|
|
|
<<: *docker_definition
|
|
|
|
image: php:7.0
|
|
|
|
stage: release
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
|
|
|
- docker pull "$TEST_IMAGE"
|
|
|
|
|
|
|
|
- docker tag "$TEST_IMAGE" "$RELEASE_IMAGE"
|
|
|
|
|
|
|
|
- docker push "$RELEASE_IMAGE"
|
|
|
|
|
|
|
|
only:
|
|
|
|
|
|
|
|
- master
|
|
|
|
|
|
|
|
|
|
|
|
test:7.1:
|
|
|
|
release-image.nginx:
|
|
|
|
<<: *test_definition
|
|
|
|
<<: *docker_definition
|
|
|
|
image: php:7.1
|
|
|
|
stage: release
|
|
|
|
|
|
|
|
script:
|
|
|
|
|
|
|
|
- docker pull "$TEST_IMAGE.nginx"
|
|
|
|
|
|
|
|
- docker tag "$TEST_IMAGE.nginx" "$RELEASE_IMAGE.nginx"
|
|
|
|
|
|
|
|
- docker push "$RELEASE_IMAGE.nginx"
|
|
|
|
|
|
|
|
only:
|
|
|
|
|
|
|
|
- master
|
|
|
|
|
|
|
|
|
|
|
|
.deploy_template: &deploy_definition
|
|
|
|
.deploy_template: &deploy_definition
|
|
|
|
services: []
|
|
|
|
|
|
|
|
stage: deploy
|
|
|
|
stage: deploy
|
|
|
|
only:
|
|
|
|
image: $TEST_IMAGE
|
|
|
|
- master
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
before_script:
|
|
|
|
- *before_fix_permissions
|
|
|
|
- apk add bash rsync openssh-client
|
|
|
|
- *before_install_packages
|
|
|
|
|
|
|
|
- *before_install_composer
|
|
|
|
|
|
|
|
- *before_install_yarn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.deploy_template_script:
|
|
|
|
.deploy_template_script:
|
|
|
|
# Configure SSH
|
|
|
|
# Configure SSH
|
|
|
@ -87,25 +99,26 @@ test:7.1:
|
|
|
|
# Install project and dependencies
|
|
|
|
# Install project and dependencies
|
|
|
|
- &deployment_dependencies |-
|
|
|
|
- &deployment_dependencies |-
|
|
|
|
chmod +x ./deploy.sh
|
|
|
|
chmod +x ./deploy.sh
|
|
|
|
apt update && apt install -yqq rsync openssh-client
|
|
|
|
cp ./deploy.sh "${DOCROOT}/deploy.sh"
|
|
|
|
composer --no-ansi install --no-dev
|
|
|
|
cd "${DOCROOT}"
|
|
|
|
composer --no-ansi dump-autoload --optimize
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build_release_file:
|
|
|
|
build-release-file:
|
|
|
|
<<: *deploy_definition
|
|
|
|
<<: *deploy_definition
|
|
|
|
|
|
|
|
stage: deploy
|
|
|
|
artifacts:
|
|
|
|
artifacts:
|
|
|
|
name: "release_${CI_COMMIT_REF_SLUG}_${CI_JOB_ID}_${CI_COMMIT_SHA}"
|
|
|
|
name: "release_${CI_COMMIT_REF_SLUG}_${CI_JOB_ID}_${CI_COMMIT_SHA}"
|
|
|
|
expire_in: 1 week
|
|
|
|
expire_in: 1 week
|
|
|
|
paths:
|
|
|
|
paths:
|
|
|
|
- ./release/
|
|
|
|
- ./release/
|
|
|
|
script:
|
|
|
|
script:
|
|
|
|
- *deployment_dependencies
|
|
|
|
- rsync -vAax "${DOCROOT}" release/
|
|
|
|
- rsync -vAax --exclude '.git*' --exclude .composer/ --exclude coverage/ --exclude node_modules/ --exclude release/ ./ release/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deploy_staging:
|
|
|
|
deploy-staging:
|
|
|
|
<<: *deploy_definition
|
|
|
|
<<: *deploy_definition
|
|
|
|
environment:
|
|
|
|
environment:
|
|
|
|
name: staging
|
|
|
|
name: staging
|
|
|
|
|
|
|
|
only:
|
|
|
|
|
|
|
|
- master
|
|
|
|
script:
|
|
|
|
script:
|
|
|
|
# Check if deployment variables where set
|
|
|
|
# Check if deployment variables where set
|
|
|
|
- |-
|
|
|
|
- |-
|
|
|
@ -118,11 +131,13 @@ deploy_staging:
|
|
|
|
# Deploy to server
|
|
|
|
# Deploy to server
|
|
|
|
- ./deploy.sh -r "${STAGING_REMOTE}" -p "${STAGING_REMOTE_PATH}" -i "${CI_JOB_ID}-${CI_COMMIT_SHA}"
|
|
|
|
- ./deploy.sh -r "${STAGING_REMOTE}" -p "${STAGING_REMOTE_PATH}" -i "${CI_JOB_ID}-${CI_COMMIT_SHA}"
|
|
|
|
|
|
|
|
|
|
|
|
deploy_production:
|
|
|
|
deploy-production:
|
|
|
|
<<: *deploy_definition
|
|
|
|
<<: *deploy_definition
|
|
|
|
environment:
|
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
name: production
|
|
|
|
when: manual
|
|
|
|
when: manual
|
|
|
|
|
|
|
|
only:
|
|
|
|
|
|
|
|
- master
|
|
|
|
script:
|
|
|
|
script:
|
|
|
|
# Check if deployment variables where set
|
|
|
|
# Check if deployment variables where set
|
|
|
|
- |-
|
|
|
|
- |-
|
|
|
|