-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
73 lines (62 loc) · 2.27 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
image: docker:stable
services:
- docker:dind
stages:
- test
- build
variables:
DOCKER_DRIVER: overlay2
TEST_CI_NAMESPACE: sms-gateway
before_script:
- docker login --username=$DOCKER_HUB_USER --password=$DOCKER_HUB_PASS
- docker login --username=$QUAY_HUB_USER --password=$QUAY_HUB_PASS quay.io
- docker login --username=$GITHUB_HUB_USER --password=$GITHUB_HUB_PASS docker.pkg.github.com
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
test:
stage: test
script:
# gc
- docker stop $TEST_CI_NAMESPACE $TEST_CI_NAMESPACE-mariadb || true
- docker rm $TEST_CI_NAMESPACE $TEST_CI_NAMESPACE-mariadb || true
- docker network rm $TEST_CI_NAMESPACE || true
- docker rmi $TEST_CI_NAMESPACE || true
# build
- docker build -f Dockerfile.ci -t $TEST_CI_NAMESPACE .
# network
- docker network create $TEST_CI_NAMESPACE
################
# Dependencies #
################
# mariadb
- |
docker run --name $TEST_CI_NAMESPACE-mariadb --network=$TEST_CI_NAMESPACE \
-e MYSQL_DATABASE="mariadb-db" \
-e MYSQL_USER="mariadb-user" \
-e MYSQL_PASSWORD="mariadb-password" \
-e MYSQL_RANDOM_ROOT_PASSWORD="true" \
-d mariadb:10
# run ci
- |
docker run --name $TEST_CI_NAMESPACE --network=$TEST_CI_NAMESPACE -e ASM_PUBLIC_APP_TEST='true' $TEST_CI_NAMESPACE /app/api/ci.sh
# gc
- docker stop $TEST_CI_NAMESPACE $TEST_CI_NAMESPACE-mariadb || true
- docker rm $TEST_CI_NAMESPACE $TEST_CI_NAMESPACE-mariadb || true
- docker network rm $TEST_CI_NAMESPACE || true
coverage: '/TOTAL_COVERAGE_FOR_CI_F: \d+\.\d+/'
build:
stage: build
script:
# build
- docker build -f Dockerfile -t aasaam/sms-gateway .
# push
- docker push aasaam/sms-gateway
# push quay.io
- |
docker image tag aasaam/sms-gateway quay.io/aasaam/sms-gateway
docker push quay.io/aasaam/sms-gateway
docker image tag aasaam/sms-gateway docker.pkg.github.com/aasaam/sms-gateway/sms-gateway
docker push docker.pkg.github.com/aasaam/sms-gateway/sms-gateway
docker image tag aasaam/sms-gateway $CI_REGISTRY/aasaam/sms-gateway:latest
docker push $CI_REGISTRY/aasaam/sms-gateway:latest
# remove image
- docker rmi aasaam/sms-gateway