Updated docker base image and synchronise consistent docker build/test
This commit is contained in:
parent
a6f01d0864
commit
10931bd156
@ -1,14 +1,14 @@
|
|||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
|
|
||||||
# This folder is cached between builds
|
# This folder is cached between builds
|
||||||
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
|
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
|
||||||
cache:
|
cache:
|
||||||
key: ${CI_COMMIT_REF_SLUG}
|
key: ${CI_JOB_NAME_SLUG}-${CI_COMMIT_REF_SLUG}
|
||||||
paths:
|
paths:
|
||||||
- vendor/
|
- vendor/
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- .gitlab-test.yml
|
- .gitlab-test.yml
|
||||||
- .gitlab-docker-x86_64.yml
|
- .gitlab-docker-x86_64.yml
|
||||||
|
@ -1,33 +1,27 @@
|
|||||||
docker:
|
docker:
|
||||||
image: docker:latest
|
variables:
|
||||||
|
VERSION: latest
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
|
||||||
stage: build
|
stage: build
|
||||||
|
|
||||||
|
image: docker:latest
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
|
|
||||||
variables:
|
|
||||||
VERSION: latest
|
|
||||||
CACHETAG: build-${VERSION}
|
|
||||||
DOCKER_HOST: tcp://docker:2375
|
|
||||||
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- x86_64
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- docker info
|
- docker info && docker version
|
||||||
- docker version
|
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
|
||||||
- echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
|
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi
|
||||||
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- if [ -f init ]; then chmod 500 init; fi
|
- if [ -f init ]; then chmod 500 init; fi
|
||||||
- ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true"
|
- echo -n ${CI_COMMIT_SHORT_SHA} > VERSION
|
||||||
- echo -n ${CI_COMMIT_SHORT_SHA} > VERSION
|
- rm -rf vendor/ database/schema database/seeders database/factories/*
|
||||||
- rm -rf vendor/ database/schema database/seeders database/factories/*
|
- docker build -t ${CI_REGISTRY_IMAGE}:${VERSION} .
|
||||||
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} .
|
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
|
||||||
- docker push ${CI_REGISTRY_IMAGE}:${VERSION}
|
tags:
|
||||||
- docker push ${CI_REGISTRY_IMAGE}:${CACHETAG}
|
- docker
|
||||||
|
- x86_64
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
test:
|
test:
|
||||||
image: ${CI_REGISTRY}/leenooks/php:8.0-fpm-latest-test
|
image: ${CI_REGISTRY}/leenooks/php:8.1-fpm-alpine-mysql-test
|
||||||
|
|
||||||
stage: test
|
stage: test
|
||||||
|
|
||||||
# NOTE: This service is dependant on project file configuration, which is not there if the cache was deleted
|
# NOTE: This service is dependant on project file configuration, which is not there if the cache was deleted
|
||||||
# resulting in the testing to fail on the first run.
|
# resulting in the testing to fail on the first run.
|
||||||
services:
|
services:
|
||||||
- mariadb:10.5
|
- mariadb:10.5
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
MYSQL_DATABASE: testing
|
MYSQL_DATABASE: testing
|
||||||
@ -15,34 +15,34 @@ test:
|
|||||||
MYSQL_PASSWORD: test
|
MYSQL_PASSWORD: test
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- php
|
- php
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- test
|
- test
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mv .env.testing .env
|
- mv .env.testing .env
|
||||||
|
|
||||||
# Install Composer and project dependencies.
|
# Install Composer and project dependencies.
|
||||||
- mkdir -p /root/.config/composer
|
- mkdir -p ${COMPOSER_HOME}
|
||||||
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > /root/.config/composer/auth.json ; fi
|
- if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > ${COMPOSER_HOME}/auth.json; fi
|
||||||
- composer install
|
- composer install
|
||||||
|
|
||||||
# Add mysql client for schema pre-load
|
# Add mysql client for schema pre-load
|
||||||
- apt update -o Acquire::ForceIPv4=true && apt install -o Acquire::ForceIPv4=true -y mariadb-client
|
- apt update -o Acquire::ForceIPv4=true && apt install -o Acquire::ForceIPv4=true -y mariadb-client
|
||||||
|
|
||||||
# Generate an application key. Re-cache.
|
# Generate an application key. Re-cache.
|
||||||
- php artisan key:generate --env=testing
|
- php artisan key:generate --env=testing
|
||||||
- php artisan config:cache --env=testing
|
- php artisan config:cache --env=testing
|
||||||
- php artisan migrate
|
- php artisan migrate
|
||||||
- php artisan db:seed
|
- php artisan db:seed
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# run laravel tests
|
# run laravel tests
|
||||||
- XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never
|
- XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never
|
||||||
|
|
||||||
# run frontend tests
|
# run frontend tests
|
||||||
# if you have any task for testing frontend
|
# if you have any task for testing frontend
|
||||||
# set it in your package.json script
|
# set it in your package.json script
|
||||||
# comment this out if you don't have a frontend test
|
# comment this out if you don't have a frontend test
|
||||||
# npm test
|
# npm test
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
FROM registry.leenooks.net/leenooks/php:8.0-fpm-latest
|
FROM registry.dege.au/leenooks/php:8.1-fpm-alpine-mysql
|
||||||
|
|
||||||
COPY . /var/www/html/
|
COPY . /var/www/html/
|
||||||
|
|
||||||
RUN export COMPOSER_HOME=/var/www/.composer \
|
RUN mkdir -p ${COMPOSER_HOME} \
|
||||||
&& mkdir -p /var/www/.composer \
|
&& ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true \
|
||||||
&& ([ -r auth.json ] && mv auth.json /var/www/.composer/) || true \
|
|
||||||
&& touch .composer.refresh \
|
&& touch .composer.refresh \
|
||||||
&& mv .env.example .env \
|
&& mv .env.example .env \
|
||||||
&& FORCE_PERMS=1 NGINX_START=FALSE /sbin/init \
|
&& FORCE_PERMS=1 NGINX_START=FALSE /sbin/init \
|
||||||
&& chmod +x /var/www/html/artisan \
|
&& chmod +x /var/www/html/artisan \
|
||||||
&& /var/www/html/artisan storage:link \
|
&& /var/www/html/artisan storage:link \
|
||||||
&& rm -rf /var/www/.composer
|
&& rm -rf ${COMPOSER_HOME}/* .git* composer.lock
|
||||||
|
Loading…
Reference in New Issue
Block a user