-
Notifications
You must be signed in to change notification settings - Fork 27
/
run-docker-builder.sh
executable file
·57 lines (45 loc) · 1.48 KB
/
run-docker-builder.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
#!/bin/bash
#
# Run a Docker builder and call the GAR builder
#
cd "$(dirname "$0")"
DirsPrefix="${HOME}/container-dirs"
while [[ $# -gt 0 ]] ; do
case "$1" in
--) shift ; break ;;
--container) Container="$2" ; shift 2 ;;
--prefix) DirsPrefix="$2" ; shift 2 ;;
*) echo "Unknown parameter: $1" ; exit 1 ;;
esac
done
if [[ "$Container" == '' ]] ; then
echo "Specify a container with --container"
exit 1
fi
ContainerFull="alisw/${Container}:latest"
# Output packages will be stored here
PackagesDirHost="${DirsPrefix}/${Container}/packages"
PackagesDirGuest='/packages_spool'
# ccache directory
CcacheDirHost="${DirsPrefix}/${Container}/ccache"
CcacheDirGuest='/ccache'
# Use latest version of the build script
BuilderHost="${PWD}/build-ib.sh"
BuilderGuest='/build-ib.sh'
# Optionally pass SVN credentials to the container
RecipeSvnCreds="$( cat "${PWD}/recipe-svn-creds.txt" 2> /dev/null )"
RecipeSvnUser=${RecipeSvnCreds%%:*}
RecipeSvnPassword=${RecipeSvnCreds#*:}
# Create external directories
mkdir -p "$PackagesDirHost" "$CcacheDirHost"
exec time docker run -it --rm \
-v "${BuilderHost}:${BuilderGuest}:ro" \
-v "${PackagesDirHost}:${PackagesDirGuest}:rw" \
-v "${CcacheDirHost}:${CcacheDirGuest}:rw" \
-e 'PS1=`[ $? == 0 ] || echo $?\|`'$Container' ~ \u@\h \w \$> ' \
-e "CCACHE_DIR=${CcacheDirGuest}" \
-e "HOME=/root" \
-e "DEFAULT_RECIPE_USER=${RecipeSvnUser}" \
-e "DEFAULT_RECIPE_PASS=${RecipeSvnPassword}" \
"$ContainerFull" \
"$BuilderGuest" "$@"