-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·65 lines (51 loc) · 1.63 KB
/
build.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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -e
if [ -z $1 ] ;
then
echo "Usage: $0 <django-basin3d-tag> (<uid> <gid>)"
exit
fi
PYTHON_VERSION=3.8
BUILD_ARGS="--build-arg PYTHON_VERSION=${PYTHON_VERSION}"
BUILD_ARGS="${BUILD_ARGS} --build-arg DJANGO_BASIN3D_VERSION=$1"
if [ ! -z $2 ] ;
then
IMAGE_UID=$2
fi
if [ ! -z $3 ] ;
then
IMAGE_GID=$3
fi
if [ ! -z $IMAGE_UID ];
then
BUILD_ARGS="${BUILD_ARGS} --build-arg IMAGE_UID=$IMAGE_UID"
fi
if [ ! -z $IMAGE_GID ];
then
BUILD_ARGS="${BUILD_ARGS} --build-arg IMAGE_GID=$IMAGE_GID"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
TAG=$1
echo "************************************"
echo " Checking for a new python image "
echo "************************************"
docker pull python:$PYTHON_VERSION
PATCH_TAG=-p$(git rev-list HEAD --count)
DOCKER_TAG="${TAG}${PATCH_TAG}"
# CREATE image_version.yml
echo "****************************"
echo "BUILDING image_version"
echo "****************************"
git log -n 1 --pretty="commit_count: $(git rev-list HEAD --count)%ncommit_hash: %h%nsubject: %s%ncommitter: %cN <%ce>%ncommiter_date: %ci%nauthor: %aN <%ae>%nauthor_date: %ai%nref_names: %D" > image_version.yml
cat image_version.yml
# Determine if there is an image
IMAGE_NAME="django-basin3d:${DOCKER_TAG}"
if [ "${REGISTRY}" != "" ];
then
# There is a registry
IMAGE_NAME="${REGISTRY}/${IMAGE_NAME}"
fi
echo "docker build ${DOCKER_BUILD_OPTIONS} -t ${IMAGE_NAME} $BUILD_ARGS ."
docker build ${DOCKER_BUILD_OPTIONS} -t ${IMAGE_NAME} $BUILD_ARGS .
echo "Taggining image as '${IMAGE_NAME%$PATCH_TAG}'"
docker tag ${IMAGE_NAME} ${IMAGE_NAME%$PATCH_TAG}