-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker_utils.sh
executable file
·33 lines (28 loc) · 1.05 KB
/
docker_utils.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
#!/bin/sh
echo $1
REPOSITORY=bcbi
IMAGE_NAME=solrplant_frontend
# Bail if we're on a dirty git tree
if ! git diff-index --quiet HEAD; then
echo "You have uncommited changes. Please commit them before building and"
echo "populating. This helps ensure that all docker images are traceable"
echo "back to a git commit."
exit 1
fi
#Get the tag from
GIT_REV=$(git log -n 1 --pretty=format:%h)
TAG="${GIT_REV}"
echo "Tag: ${TAG}"
if [ "$1" == "build-and-push" ]; then
docker build --tag=${REPOSITORY}/${IMAGE_NAME}:${TAG} .
docker push ${REPOSITORY}/${IMAGE_NAME}:${TAG}
docker tag ${REPOSITORY}/${IMAGE_NAME}:${TAG} ${REPOSITORY}/${IMAGE_NAME}:latest
docker push ${REPOSITORY}/${IMAGE_NAME}:latest
echo "Pushed ${REPOSITORY}/${IMAGE_NAME}:${TAG} and :latest"
elif [ "$1" == "run-dev" ]; then
docker run -it -p 3000:3000 --name ${IMAGE_NAME} ${REPOSITORY}/${IMAGE_NAME}:latest
elif [ "$1" == "rm" ]; then
docker rm ${IMAGE_NAME}
else
echo "First argument must be one of the following strings: build-and-push, run-dev, rm"
fi