-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·113 lines (89 loc) · 2.95 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
set -e
if [ -z $1 ] ;
then
echo "Usage: $0 <metacatui_tag> (<uid> <gid>)"
exit
fi
BUILD_ARGS=""
if [ ! -z $2 ] ;
then
ESSDIVE_UID=$2
fi
if [ ! -z $3 ] ;
then
ESSDIVE_GID=$3
fi
if [ ! -z $ESSDIVE_UID ];
then
BUILD_ARGS="${BUILD_ARGS} --build-arg METACATUI_UID=$ESSDIVE_UID"
fi
if [ ! -z $ESSDIVE_GID ];
then
BUILD_ARGS="${BUILD_ARGS} --build-arg METACATUI_GID=$ESSDIVE_GID"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
METACATUI_TAG=$1
# Get Metacat UI
if [ ! -d $DIR/metacatui ];
then
git clone https://github.com/NCEAS/metacatui.git $DIR/metacatui
fi
cd $DIR/metacatui
git fetch
git checkout tags/${METACATUI_TAG}
cd ..
echo "************************************"
echo " Checking for a new httpd:2.4 image "
echo "************************************"
# Get the current image id
if [ ! -z "`docker image ls httpd:2.4 | grep httpd`" ];
then
ID_IMAGE_LOCAL=`docker inspect --format='{{.Id}}' httpd:2.4`
fi
docker pull httpd:2.4
# Get the new image id
ID_IMAGE_REMOTE=`docker inspect --format='{{.Id}}' httpd:2.4`
echo "ID_IMAGE_LOCAL $ID_IMAGE_LOCAL"
echo "ID_IMAGE_REMOTE $ID_IMAGE_REMOTE"
if [ ! -z $ID_IMAGE_LOCAL ] && [ "$ID_IMAGE_REMOTE" != "$ID_IMAGE_LOCAL" ];
then
echo "***********************************"
echo "A new httpd:2.4 image was pulled"
echo "***********************************"
docker run --entrypoint "/bin/cat" httpd:2.4 conf/httpd.conf > image-httpd.conf
docker run --entrypoint "/bin/cat" httpd:2.4 conf/extra/httpd-ssl.conf > image-httpd-ssl.conf
DIFF_CONFS=`git diff image-httpd.conf image-httpd-ssl.conf`
if [ ! -z $DIFF_CONFS ];
then
echo "***************************************"
echo "One of the image configs is different"
echo "You need to review for patch changes"
echo ""
echo "diffs:$DIFF_CONFS"
echo ""
echo "Create new patch files of the new"
echo " configurations"
echo "diff -u image-httpd.conf httpd.conf > httpd.conf.patch"
echo "diff -u image-httpd-ssl.conf httpd-ssl.conf > httpd-ssl.conf.patch"
echo "***********************************"
exit 1
fi
fi
cd $DIR
DOCKER_TAG="${METACATUI_TAG}-p$(cd $DIR; git rev-list HEAD --count)"
# 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="metacatui:${DOCKER_TAG}"
if [ "${REGISTRY_SPIN}" != "" ];
then
# There is a spin registry
IMAGE_NAME="${REGISTRY_SPIN}/${IMAGE_NAME}"
fi
echo "docker build ${DOCKER_BUILD_OPTIONS} -t ${IMAGE_NAME} $BUILD_ARGS ."
docker build ${DOCKER_BUILD_OPTIONS} -t ${IMAGE_NAME} $BUILD_ARGS .