-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-image-release.sh
More file actions
executable file
·90 lines (77 loc) · 2.62 KB
/
Copy pathdocker-image-release.sh
File metadata and controls
executable file
·90 lines (77 loc) · 2.62 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
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
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
#
# script filename
SCRIPT_NAME=$(basename $BASH_SOURCE)
echo ""
echo ""
#
# check that we got two arguments in input
if [ "$#" -ne 1 ]; then
echo "Usage ${SCRIPT_NAME} <account> (<tag>)"
echo ""
echo " prepare a docker image and push it to the dockerhub repo in the repository <account>/panosc-federated-search"
echo ""
echo " arguments:"
echo " - tag = git tag or commit we would like to use to create the image"
echo " if not specified the tag ysed will be the branch name followed by the latest commit, separted by dash"
echo " Example:"
echo " - 5d5f42af1ca6816a13b6db60b4778388dc4bf431-develop"
echo ""
exit 1
fi
# extract input argument
gitTag=$1
# code repository and branch
# these are not needed anymore as we assume that this script will only be run from within the repo
# after it has been cloned from github.
#
# I leave them here as a reference as they change as of 2021/11/09
# githut repository = https://github.com/panosc-eu/panosc-federated-search-service.git
# available branches
# - master,
# - develop
# docker repository
dockerRepo=ghcr.io/panosc-eu/panosc-federated-search-service
# check if the user provided a tag or not
if [ "-${gitTag}-" == "--" ]; then
# not git tag from the user
# define git tag as <branch>-<latest commit>
gitTag="$(git branch --show-current)-$(git rev-parse HEAD)"
else
# check out on the specific commit or tag
git checkout ${gitTag}
fi
typeTag="latest"
if [ ${gitTag} == "z*" ]; then
typeTag="stable"
fi
# docker image tag
dockerTag="${gitTag}"
dockerImage="${dockerRepo}:${dockerTag}"
dockerImageVersionTag="${dockerImage}"
dockerImageTypeTag="${dockerRepo}:${typeTag}"
#
# gives some feedback to the user
echo "Account : ${account}"
echo "Git commit tag : ${gitTag}"
echo "Docker tag : ${dockerTag}"
echo "Docker image : ${dockerImage}"
echo "Docker image git tag : ${dockerImageVersionTag}"
echo "Docker image type tag : ${dockerImageTypeTag}"
echo ""
#
# create docker image
# if it is already present, remove old image
if [[ "$(docker images -q ${dockerImage} 2> /dev/null)" != "" ]]; then
echo "Image already present. Removing it and recreating it"
docker rmi ${dockerImageGitTag}
echo ""
fi
echo "Creating image"
docker build -t ${dockerImageVersionTag} -t ${dockerImageTypeTag} --build-arg PROVIDERS=${PROVIDERS} --build-arg API_VERSION=${gitTag} --build-arg DOCKER_IMAGE_VERSION=${gitTag} -f ./search-api/Dockerfile ./search-api
echo ""
# push image on docker hub repository
docker push ${dockerImage}
echo ""
echo "Done"
echo ""