forked from 0chain/0chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_docker.sh
executable file
·52 lines (48 loc) · 2.44 KB
/
build_docker.sh
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
#!/usr/bin/env bash
ZCM="miner"
ZCS="sharder"
read -p "Provide the docker image tag name: " TAG
read -p "Provide the github organisation name[default:-0chaintest]: " organisation
echo "${organisation:-0chaintest}/${ZCM}:$TAG"
echo "${organisation:-0chaintest}/${ZCS}:$TAG"
REGISTRY_MINER="${organisation:-0chaintest}/${ZCM}"
REGISTRY_SHARDER="${organisation:-0chaintest}/${ZCS}"
DOCKERFILE_MINER="docker.local/build.miner/Dockerfile"
DOCKERFILE_SHARDER="docker.local/build.sharder/Dockerfile"
ZCHAIN_BUILDBASE="zchain_build_base"
ZCHAIN_BUILDRUN="zchain_run_base"
GIT_COMMIT=$(git rev-list -1 HEAD)
echo $GIT_COMMIT
if [ -n "$TAG" ]; then
echo " $TAG is the tage name provided"
echo -e " Creating 0chain docker the base images..\n"
sudo docker build -f docker.local/build.base/Dockerfile.build_base . -t ${ZCHAIN_BUILDBASE}
sudo docker build -f docker.local/build.base/Dockerfile.run_base docker.local/build.base -t ${ZCHAIN_BUILDRUN}
sudo docker system info | grep -E 'Username' 1>/dev/null
if [[ $? -ne 0 ]]; then
docker login
fi
echo -e "${ZCM}: Docker image build is started.. \n"
sed 's,%COPY%,COPY --from=miner_build $APP_DIR,g' "$DOCKERFILE_MINER.template" > "$DOCKERFILE_MINER"
sudo docker build --build-arg GIT_COMMIT=$GIT_COMMIT -t ${REGISTRY_MINER}:${TAG} -f "$DOCKERFILE_MINER" .
# sudo docker pull ${REGISTRY_MINER}:latest
# sudo docker tag ${REGISTRY_MINER}:latest ${REGISTRY_MINER}:stable_latest
# echo "Re-tagging the remote latest tag to stable_latest"
# sudo docker push ${REGISTRY_MINER}:stable_latest
# sudo docker tag ${REGISTRY_MINER}:${TAG} ${REGISTRY_MINER}:latest
# echo "Pushing the new latest tag to dockerhub"
# sudo docker push ${REGISTRY_MINER}:latest
echo "Pushing the new tag to dockerhub tagged as ${REGISTRY_MINER}:${TAG}"
sudo docker push ${REGISTRY_MINER}:${TAG}
echo -e "${ZCS}: Docker image build is started.. \n"
sudo docker build --build-arg GIT_COMMIT=$GIT_COMMIT -t ${REGISTRY_SHARDER}:${TAG} -f "$DOCKERFILE_SHARDER" .
# sudo docker pull ${REGISTRY_SHARDER}:latest
# sudo docker tag ${REGISTRY_SHARDER}:latest ${REGISTRY_SHARDER}:stable_latest
# echo "Re-tagging the remote latest tag to stable_latest"
# sudo docker push ${REGISTRY_SHARDER}:stable_latest
# sudo docker tag ${REGISTRY_SHARDER}:${TAG} ${REGISTRY_SHARDER}:latest
# echo "Pushing the new latest tag to dockerhub"
# sudo docker push ${REGISTRY_SHARDER}:latest
echo "Pushing the new tag to dockerhub tagged as ${REGISTRY_SHARDER}:${TAG}"
sudo docker push ${REGISTRY_SHARDER}:${TAG}
fi