forked from mercure-imaging/mercure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker.sh
executable file
·98 lines (86 loc) · 2.65 KB
/
build-docker.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
#!/bin/bash
set -euo pipefail
#################################################################
# Create mercure from scratch in Docker environment
#################################################################
#
# Make sure to change the configuration below, as they are most
# likely different for your environment
#
# Once you are happy, simply run this script to build mercure
# See docker/docker-compose.yml for a sample script
#
#################################################################
#################################################################
# CONFIG SECTION
#################################################################
# Change prefix to your own Docker prefix if you want to make
# your own custom build
PREFIX="mercureimaging"
# Read the version of the mercure source, which will be used for
# tagging the Docker images, unless a tag has been provided
# through the environment variable MERCURE_TAG
if [ ! -f "VERSION" ]; then
echo "Error: VERSION file missing. Unable to proceed."
exit 1
fi
VERSION=`cat VERSION`
TAG=${MERCURE_TAG:-$VERSION}
# Define where mercure is going to store things
# You can redefine types of volumes in docker/docker-compose.yml
MERCUREBASE=/opt/mercure
DATADIR=$MERCUREBASE/data
CONFIGDIR=$MERCUREBASE/config
DBDIR=$MERCUREBASE/db
MERCURESRC=./
#################################################################
# BUILD SECTION
#################################################################
echo "Building Docker containers for mercure $VERSION"
echo "Using image tag $TAG"
echo ""
FORCE_BUILD="n"
CACHE="--no-cache"
while getopts ":yc" opt; do
case ${opt} in
y )
FORCE_BUILD="y"
;;
c )
CACHE=""
;;
\? )
echo "Invalid Option: -$OPTARG" 1>&2
exit 1
;;
: )
echo "Invalid Option: -$OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
if [ $FORCE_BUILD = "y" ]; then
echo "Forcing building"
else
read -p "Proceed (y/n)? " ANS
if [ "$ANS" = "y" ]; then
echo ""
else
echo "Aborted."
exit 0
fi
fi
build_component () {
docker build docker/$1 -t $PREFIX/mercure-$1:$TAG -t $PREFIX/mercure-$1:latest --build-arg VERSION_TAG=$TAG
}
docker build $CACHE -t $PREFIX/mercure-base:$TAG -t $PREFIX/mercure-base:latest -f docker/base/Dockerfile .
for component in ui bookkeeper receiver router processor dispatcher cleaner
do
build_component $component
done
docker build nomad/sshd -t $PREFIX/alpine-sshd:latest
docker build nomad/processing -t $PREFIX/processing-step:$TAG -t $PREFIX/processing-step:latest
docker build nomad/dummy-processor -t $PREFIX/mercure-dummy-processor:$TAG -t $PREFIX/processing-step:latest
echo ""
echo "Done."
echo ""