Refactors .gitlab-ci.yml, closes closes
---
-image: docker:latest
+variables:
+ GROUP_NAME: "{{ cookiecutter.organization }}"
+ PROJECT_NAME: "{{ cookiecutter.project_name }}"
+# This is a base job template for all `docker`-based jobs. It won't be executed.
+.docker:
+ image: docker:latest
variables:
# When using dind, it's wise to use the overlayfs driver for
# improved performance:
DOCKER_DRIVER: overlay2
- PROJECT_NAME: "{{ cookiecutter.project_name }}"
- GROUP_NAME: "{{ cookiecutter.organization }}"
REGISTRY: "registry.gitlab.com"
CONTAINER_RELEASE_IMAGE: "$REGISTRY/$GROUP_NAME/$PROJECT_NAME:latest"
-
services:
- docker:dind
-
before_script:
# Installing global dependencies:
- apk update && apk upgrade
- apk add python3 python3-dev py3-pip git build-base
- pip3 install -U pip
- - pip3 install dump-env docker-compose docker-image-size-limit
+ - pip3 install dump-env docker-image-size-limit 'docker-compose<1.24'
# Creating `.env` configuration file:
- dump-env -t config/.env.template -p 'SECRET_' > config/.env
# Login into Docker registry:
@@ -29,16 +30,22 @@ before_script:
# Testing application:
test:
+ extends: .docker
stage: test
script:
- docker-compose -f docker-compose.yml
-f docker/docker-compose.prod.yml config --quiet
- docker-compose run --rm web sh ./docker/ci.sh
- - disl "${PROJECT_NAME}_web:latest" 500MiB
+ - disl "${PROJECT_NAME}_web:latest" 650MiB
coverage: '/[\d\.]+\%\s*$/'
+ except:
+ - master
+ - schedules
+ - tags
-# Releasing image, when tests pass:
+# Releasing image, when in `master` branch:
release-image:
+ extends: .docker
stage: deploy
script:
- docker build -t "$CONTAINER_RELEASE_IMAGE"
