-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
53 lines (46 loc) · 1.42 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
image: docker:19.03.12
services:
- name: docker:19.03.12-dind
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:test
CONTAINER_DEV_IMAGE: $CI_REGISTRY_IMAGE:dev
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
stages:
- build
- test
- release_dev
- release
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:
stage: build
script:
- docker build --pull -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
test:
stage: test
script:
- docker network create --driver bridge ergo
- docker pull postgres
- docker run --name db -e POSTGRES_DB=db_accounting -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin -e PG_ROOT_PASSWORD=admin --network="ergo" --hostname="db" -d postgres
- sleep 4
- docker pull $CONTAINER_TEST_IMAGE
- docker run --network="ergo" $CONTAINER_TEST_IMAGE ./script.sh
release_dev:
stage: release_dev
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_DEV_IMAGE
- docker push $CONTAINER_DEV_IMAGE
release:
stage: release
rules:
- if: '$CI_COMMIT_TAG'
script:
- docker build --cache-from $CI_REGISTRY_IMAGE:dev -t $CONTAINER_RELEASE_IMAGE .
- docker push $CONTAINER_RELEASE_IMAGE