-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
78 lines (74 loc) · 2.06 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
variables:
DOCKER_PROXY: $REGISTRY_NAME:5556
REGISTRY: $REGISTRY_NAME:$REGISTRY_PORT
DOCKER_COMPOSE: 'docker-compose -f docker-compose.yml -f docker-compose.test.yml'
stages:
- build
- test
- deploy
build app:
image: ${DOCKER_PROXY}/tmaier/docker-compose:20.10
stage: build
services:
- name: ${DOCKER_PROXY}/docker:20.10-dind-asyril
alias: docker
before_script:
- docker version
- docker-compose version
# Login to our registry
- docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD $REGISTRY
variables:
CONTAINER_IMAGE: $CI_PIPELINE_ID
script:
# Build and push the images to the registry
- $DOCKER_COMPOSE build
- $DOCKER_COMPOSE push
unit test:
image: ${DOCKER_PROXY}/tmaier/docker-compose:20.10
stage: test
services:
- name: ${DOCKER_PROXY}/docker:20.10-dind-asyril
alias: docker
before_script:
- docker version
- docker-compose version
variables:
CONTAINER_IMAGE: $CI_PIPELINE_ID
script:
- $DOCKER_COMPOSE pull --quiet log-viewer-test
- $DOCKER_COMPOSE run --rm --no-deps log-viewer-test
artifacts:
when: always
reports:
junit:
- test/report/junit.xml
interruptible: true
deploy app:
image: ${DOCKER_PROXY}/tmaier/docker-compose:20.10
stage: deploy
services:
- name: ${DOCKER_PROXY}/docker:20.10-dind-asyril
alias: docker
before_script:
- docker version
- docker-compose version
- apk add git openssh-client
# Adding SSH KEY for accessing host docker through ssh
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- eval $(ssh-agent -s)
- echo "$BUILDSERVER_SSH_KEY" | tr -d '\r' | ssh-add -
# Adding host key to avoid "Host key verification failed."
- ssh-keyscan $DEPLOY_HOST >> ~/.ssh/known_hosts
variables:
CONTAINER_IMAGE: $CI_PIPELINE_ID
DEPLOY_HOST: $BUILDSERVER_HOST
script:
- export DOCKER_HOST=ssh://gitlab@$DEPLOY_HOST
- $DOCKER_COMPOSE pull
- $DOCKER_COMPOSE down --remove-orphans
- $DOCKER_COMPOSE up -d --no-build
environment:
name: Registry
when: manual
needs: ['build app']