-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
59 lines (53 loc) · 1.69 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
image: docker:latest
variables:
# When using dind, it's wise to use the overlayfs driver for
# improved performance:
DOCKER_DRIVER: overlay2
PROJECT_NAME: "notes_backend"
GROUP_NAME: "wemake.services"
PIPENV_SHELL_COMPAT: "true"
PIPENV_COLORBLIND: "true"
PIPENV_NOSPIN: "true"
CONTAINER_TEST_IMAGE: "registry.gitlab.com/$GROUP_NAME/$PROJECT_NAME:$CI_BUILD_REF_NAME"
CONTAINER_RELEASE_IMAGE: "registry.gitlab.com/$GROUP_NAME/$PROJECT_NAME:latest"
services:
- docker:dind
before_script:
# Installing docker-compose:
- apk update && apk upgrade
- apk add python python-dev py-pip git build-base
- pip install dump-env docker-compose
# Creating `.env` configuration file:
- dump-env -t config/.env.template -p 'SECRET_' > config/.env
# Login into Docker registry:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
# Debug information:
- docker info && docker-compose --version && git --version
# Build Docker container and push it to the Gitlab's registry:
build:
stage: build
script:
- docker build -t $CONTAINER_TEST_IMAGE --build-arg DJANGO_ENV=production -f docker/django/Dockerfile .
- docker push $CONTAINER_TEST_IMAGE
only:
- master
# Testing application:
test:
stage: test
script:
- docker-compose run -e INSIDE_CI=1 web sh ./docker/ci.sh
coverage: '/\d+\%\s*$/'
artifacts:
paths:
- artifacts/
# Releasing image, when tests pass:
release-image:
stage: deploy
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master
environment:
name: production # used to track time with 'cycle analytics'