-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'use-plain-docker-in-build'
- Loading branch information
Showing
2 changed files
with
18 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,57 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
echo "GITHUB_REF: ${GITHUB_REF}" | ||
IMAGE="mklocke/liga-manager-api" | ||
|
||
if [[ $GITHUB_REF == *"refs/tags"* ]]; then | ||
TAG=$(sed 's#refs/tags/##' <<< "${GITHUB_REF}") | ||
else | ||
TAG="latest" | ||
fi | ||
|
||
echo "GITHUB_REF: ${GITHUB_REF}" | ||
echo "IMAGE: ${IMAGE}" | ||
echo "TAG: ${TAG}" | ||
|
||
# Pull images | ||
TAG=$TAG docker-compose -f docker-compose.build.yml pull | ||
docker pull mariadb:10.4 | ||
docker pull redis:5-alpine | ||
docker pull $IMAGE:$TAG | ||
|
||
# Build images | ||
TAG=$TAG docker-compose -f docker-compose.build.yml build | ||
docker build -f docker/php/Dockerfile -t $IMAGE:$TAG --cache-from $IMAGE:latest . | ||
|
||
cleanup() { | ||
echo 'Cleanup: Removing containers ...' | ||
TAG=$TAG docker-compose -f docker-compose.build.yml down -v | ||
docker rm -f php mariadb redis | ||
docker network rm build | ||
} | ||
|
||
# Make sure we clean up running containers in case of error | ||
trap cleanup EXIT | ||
|
||
# Launch containers | ||
TAG=$TAG docker-compose -f docker-compose.build.yml up -d | ||
docker network create build | ||
docker run -d --name=mariadb --network=build --env-file=build.env mariadb:10.4 | ||
docker run -d --name=redis --network=build redis:5-alpine | ||
docker run -d --name=php --network=build --env-file=build.env $IMAGE:$TAG | ||
|
||
# Run deptrac | ||
TAG=$TAG docker-compose -f docker-compose.build.yml exec -T php bin/deptrac.phar --no-progress | ||
docker exec -t php bin/deptrac.phar --no-progress | ||
|
||
# Run tests without coverage | ||
TAG=$TAG docker-compose -f docker-compose.build.yml exec -T php run-tests.sh | ||
docker exec -t php run-tests.sh | ||
|
||
if [[ ! -z "${CI}" ]]; then | ||
# Enable xdebug | ||
TAG=$TAG docker-compose -f docker-compose.build.yml exec -T -u root php docker-php-ext-enable xdebug | ||
docker exec -t -u root php docker-php-ext-enable xdebug | ||
|
||
# Run tests with coverage | ||
TAG=$TAG docker-compose -f docker-compose.build.yml exec -T -e COVERAGE_REPORT=1 -e COVERALLS_RUN_LOCALLY -e COVERALLS_REPO_TOKEN php run-tests.sh | ||
docker exec -t -e COVERAGE_REPORT=1 -e COVERALLS_RUN_LOCALLY -e COVERALLS_REPO_TOKEN php run-tests.sh | ||
|
||
# Login to docker hub | ||
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin | ||
|
||
# Push image to docker hub | ||
docker push mklocke/liga-manager-api:$TAG | ||
docker push $IMAGE:$TAG | ||
fi |
This file was deleted.
Oops, something went wrong.