comparison deploy/linux/docker/build.sh @ 1539:56b268b96fcb

Some Ubuntu/Fedora docker build material
author Chris Cannam
date Thu, 12 Jan 2017 14:09:44 +0000
parents
children 12b96d6b1d66
comparison
equal deleted inserted replaced
1538:06f061c54b66 1539:56b268b96fcb
1 #!/bin/bash
2
3 version=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h | sed 's/-//g')
4
5 dockerdir=./deploy/linux/docker
6 if [ ! -d "$dockerdir" ]; then
7 echo "Run this script from the build root"
8 exit 2
9 fi
10
11 platform="$1"
12
13 if [ -z "$platform" ] || [ -n "$2" ]; then
14 echo "Usage: $0 <platform>"
15 echo "where <platform> matches the suffix of the Docker file, e.g. ubuntu1604"
16 exit 2
17 fi
18
19 set -eu
20
21 echo "Building for version $version, platform $platform"
22 dockerfile="Dockerfile_v${version}_${platform}"
23
24 if [ ! -f "$dockerdir/$dockerfile" ]; then
25 echo "No matching docker file $dockerfile found in $dockerdir"
26 exit 1
27 fi
28
29 dockertag="cannam/sonic-visualiser-$platform"
30
31 sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir"
32
33 outdir="$dockerdir/output"
34 mkdir -p "$outdir"
35
36 container=$(sudo docker create "$dockertag")
37 sudo docker cp "$container":output.tar "$outdir"
38 sudo docker rm "$container"
39
40 ( cd "$outdir" ; tar xf output.tar && rm -f output.tar )
41
42 echo
43 echo "Done, output directory contains:"
44 ls -ltr "$outdir"