-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·43 lines (38 loc) · 1.06 KB
/
docker.sh
File metadata and controls
executable file
·43 lines (38 loc) · 1.06 KB
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
#! /bin/bash
# This script builds and publish docker images.
# If tag is specified, it will create both docker and git tags.
#
# Usage: ./docker.sh mainnet|testnet [tagname]
# For example: ./docker.sh testnet v1.1.0
# will build the app for testnet
# and publish 1 image with 2 tags:
# sihoang/staking-dapp:testnet-latest
# sihoang/staking-dapp:testnet-v1.1.0
# it also creates `git tag <tagname>`
#
# To specify docker repo
# DOCKER_REPO="sihoang/staking-dapp" ./docker.sh
DOCKER_REPO=${DOCKER_REPO:-"wetrustplatform/staking-dapp"}
DOCKER_IMAGE="$DOCKER_REPO:$1-latest"
if [ "$1" == "testnet" -o "$1" == "mainnet" ]; then
docker build \
-t $DOCKER_IMAGE \
-f Dockerfile.$1 \
.
else
echo "Please specify either testnet or mainnet!"
exit 1
fi
echo ">> Pushing image $DOCKER_IMAGE to registry"
docker push $DOCKER_IMAGE
if [ -z "$2" ]; then
echo ">> No tag specified"
exit 0
else
echo ">> Tag $2"
git tag $2
DOCKER_TAG="$DOCKER_REPO:$1-$2"
docker tag $DOCKER_IMAGE $DOCKER_TAG
echo ">> Pushing tag $DOCKER_TAG to registry"
docker push $DOCKER_TAG
fi