forked from convertigo/convertigo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkDockerLocal.sh
executable file
·70 lines (55 loc) · 2.04 KB
/
mkDockerLocal.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
#!/bin/sh
dir=$( cd -P $(dirname $0); pwd)
if ! command -v docker >/dev/null 2>&1 || ! docker ps >/dev/null 2>&1 ; then
echo "Need a shell environment with a working 'docker' command"
exit 5
fi
case "$1" in
"build") REBUILD=false;;
"rebuild") REBUILD=true;;
*) echo "Missing arguments:\nbuild [i386|alpine]\nAlso rebuild base: rebuild [i386|alpine]"
exit 1;;
esac
case "$2" in
"i386") export TYPE=i386 WAR="linux32-";;
"alpine") export TYPE=alpine WAR="";;
"") export TYPE=amd64 WAR="";;
*) echo "Bad argument: |i386|alpine"
exit 2;;
esac
export CONVERTIGO_VERSION_NUMBER=$(sed -n "s/def convertigoVersion = '\(.*\)'/\\1/p" $dir/build.gradle)
export CONVERTIGO_VERSION_TAG=$(sed -n "s/def convertigoTag = '\(.*\)'/\\1/p" $dir/build.gradle)
if [ "$CONVERTIGO_VERSION_TAG" = "" ] ; then
export CONVERTIGO_VERSION=$CONVERTIGO_VERSION_NUMBER
else
export CONVERTIGO_VERSION=$CONVERTIGO_VERSION_NUMBER-$CONVERTIGO_VERSION_TAG
fi
WAR_FILE=$dir/engine/build/libs/convertigo-${WAR}${CONVERTIGO_VERSION}.war
if [ ! -f $WAR_FILE ]; then
echo "Missing the WAR (not built ?): $WAR_FILE"
exit 3
fi
echo "Using the WAR: $WAR_FILE"
rm -rf $dir/workspace/docker
cp -r $dir/docker $dir/workspace
(
cd $dir/workspace/docker
export FROM=$(eval echo $(sed -n "s/FROM \(.*\)/\1/p" Dockerfile))
echo "Searching for the base: $FROM"
if [ "$REBUILD" = true ] || ! docker pull $FROM ; then
echo "Building: $FROM"
if [ $TYPE = "i386" ]; then
sed -i "s,tomcat:,i386/tomcat:," Dockerfile_base
fi
if [ $TYPE = "alpine" ]; then
docker build --rm=false -f alpine/Dockerfile_base -t $FROM alpine
else
docker build --rm=false -f Dockerfile_base -t $FROM .
fi
fi
sed -i -e "s,RUN curl.*,COPY convertigo.war /tmp/convertigo.war," -e "s, \\(&& mkdir\\),RUN chmod a+x /*.sh \\1," Dockerfile
ln -s $WAR_FILE convertigo.war
docker build --rm=false -t c8o:$TYPE --build-arg TYPE=$TYPE .
docker tag c8o:$TYPE c8o:latest
echo "All is done, the image is accessible from c8o:$TYPE or c8o:latest"
)