This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.drone.yml
79 lines (76 loc) · 3.71 KB
/
.drone.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
79
kind: pipeline
name: default
steps:
- name: integration
image: enigmampc/docker-client
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
commands:
- git clone https://github.com/enigmampc/discovery-docker-network.git
- cd discovery-docker-network && cp .env-template .env
- sed -i "s/COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=enigma_${DRONE_BUILD_NUMBER}/" .env
- export MATCHING_BRANCH_CORE="$(git ls-remote --heads https://github.com/enigmampc/enigma-core.git ${DRONE_BRANCH} | wc -l)"
- export MATCHING_BRANCH_P2P="$(git ls-remote --heads https://github.com/enigmampc/enigma-p2p.git ${DRONE_BRANCH} | wc -l)"
- export DOCKER_TAG=p2p_${DRONE_BUILD_NUMBER}
- sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=${DOCKER_TAG}/" .env;
- |
/bin/bash -c '
declare -a PROJECTS=(core km p2p)
declare -A DOCKER_IMAGES=([core]=enigma_core_hw [km]=enigma_km_hw [p2p]=enigma_p2p)
declare -A GIT_BRANCH_ARG=([core]=GIT_BRANCH_CORE [km]=GIT_BRANCH_CORE [p2p]=GIT_BRANCH_P2P)
declare -A PROJECT_DIRECTORY=([core]=enigma-core [km]=enigma-core [p2p]=enigma-p2p)
declare -A PROJECT_BRANCH_FOUND=([core]=$MATCHING_BRANCH_CORE [km]=$MATCHING_BRANCH_CORE [p2p]=$MATCHING_BRANCH_P2P)
for project in $${PROJECTS[@]}; do
DOCKER_IMAGE="enigmampc/$${DOCKER_IMAGES[$project]}"
if [[ "$DRONE_BRANCH" == "master" ]]; then
docker pull "$DOCKER_IMAGE:latest"
docker tag "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$DOCKER_TAG"
elif [ "$${PROJECT_BRANCH_FOUND[$project]}" -eq 0 ]; then
docker pull "$DOCKER_IMAGE:develop"
docker tag "$DOCKER_IMAGE:develop" "$DOCKER_IMAGE:$DOCKER_TAG"
else
cd "$${PROJECT_DIRECTORY[$project]}"
if [[ "$project" == "km" ]]; then
docker build -f Dockerfile.km --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
elif [[ "$project" == "core" ]]; then
docker build --build-arg GIT_BRANCH_CORE=${DRONE_BRANCH} --build-arg SGX_MODE=HW -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
else
docker build --build-arg "$${GIT_BRANCH_ARG[$project]}=${DRONE_BRANCH}" -t "$DOCKER_IMAGE:$DOCKER_TAG" --no-cache .
fi
cd ..
fi
done'
- cd enigma-contract && docker build --build-arg GIT_BRANCH_CONTRACT=${DRONE_BRANCH} -t enigmampc/enigma_contract:$DOCKER_TAG --no-cache . && cd ..
- export NODES=3
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml -f docker-compose.test.yml up --scale core=$NODES --scale p2p=$NODES --exit-code-from client && export RESULT=$? || export RESULT=$?
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml down -v --rmi all || true
- if [ $RESULT -ne 0 ]; then exit 1; fi
- name: deploy
image: enigmampc/docker-client
depends_on:
- integration
when:
branch:
- develop
- master
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
environment:
USERNAME:
from_secret: username
PASSWORD:
from_secret: password
commands:
- cd discovery-docker-network/enigma-contract
- echo $PASSWORD | docker login -u $USERNAME --password-stdin
- if [[ ${DRONE_BRANCH} == "master" ]]; then export DOCKER_TAG=latest; else export DOCKER_TAG=develop; fi
- docker build --build-arg GIT_BRANCH_CONTRACT=${DRONE_BRANCH} -t enigmampc/enigma_contract:$DOCKER_TAG --no-cache .
- docker push enigmampc/enigma_contract:$DOCKER_TAG
volumes:
- name: sock
host:
path: /var/run/docker.sock