postal/.gitlab-ci.yml
2020-04-18 22:04:29 -04:00

70 lines
1.8 KiB
YAML

#variables:
before_script:
- docker info
stages:
- build
- tests
- upload
build-docker-alpine:
stage: build
script:
- cd alpine
- docker build --network=host -t catdeployed/postal:alpine .
- docker save -o postal-alpine-container.tar catdeployed/postal:alpine
artifacts:
paths:
- alpine/postal-alpine-container.tar
expire_in: 1 day
build-docker-ubuntu:
stage: build
script:
- cd ubuntu
- docker build --network=host -t catdeployed/postal:ubuntu .
- docker save -o postal-ubuntu-container.tar catdeployed/postal:ubuntu
artifacts:
paths:
- ubuntu/postal-ubuntu-container.tar
expire_in: 1 day
test-docker-ubuntu:
stage: tests
script:
- cd ubuntu
- docker load -i postal-ubuntu-container.tar
- docker-compose up -d
- for i in {1..20}; do [ $(docker inspect postal | jq '.[].State.Health.Status') == "healthy" ] && break || sleep 15; done
after_script:
- cd ubuntu
- docker-compose rm -sfv
test-docker-alpine:
stage: tests
script:
- cd alpine
- docker load -i postal-alpine-container.tar
- docker-compose up -d
- for i in {1..20}; do [ $(docker inspect postal | jq '.[].State.Health.Status') == "healthy" ] && break || sleep 15; done
after_script:
- cd alpine
- docker-compose rm -sfv
upload-images:
stage: upload
script:
- docker load -i ubuntu/postal-ubuntu-container.tar
- docker load -i alpine/postal-alpine-container.tar
- docker tag catdeployed/postal:alpine catdeployed/postal:latest
- docker login -u$DOCKER_USER -p$DOCKER_PASS
- docker push catdeployed/postal:alpine
- docker push catdeployed/postal:ubuntu
- docker push catdeployed/postal:latest
only:
- master@CatDeployed/docker-postal
after_script:
- docker container prune -f
- docker image prune -f
- docker system prune -af --volumes