annotate deploy/linux/docker/build.sh @ 1701:5a6068ba6c24

Change of plan; this will be 3.0.3. I'm not going to make any more substantial fixes, so it's not a big enough change for 3.1, but I don't want to hold off the release for long. And hey, it's 303
author Chris Cannam
date Thu, 25 May 2017 09:24:01 +0100
parents 56b268b96fcb
children 12b96d6b1d66
rev   line source
Chris@1539 1 #!/bin/bash
Chris@1539 2
Chris@1539 3 version=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h | sed 's/-//g')
Chris@1539 4
Chris@1539 5 dockerdir=./deploy/linux/docker
Chris@1539 6 if [ ! -d "$dockerdir" ]; then
Chris@1539 7 echo "Run this script from the build root"
Chris@1539 8 exit 2
Chris@1539 9 fi
Chris@1539 10
Chris@1539 11 platform="$1"
Chris@1539 12
Chris@1539 13 if [ -z "$platform" ] || [ -n "$2" ]; then
Chris@1539 14 echo "Usage: $0 <platform>"
Chris@1539 15 echo "where <platform> matches the suffix of the Docker file, e.g. ubuntu1604"
Chris@1539 16 exit 2
Chris@1539 17 fi
Chris@1539 18
Chris@1539 19 set -eu
Chris@1539 20
Chris@1539 21 echo "Building for version $version, platform $platform"
Chris@1539 22 dockerfile="Dockerfile_v${version}_${platform}"
Chris@1539 23
Chris@1539 24 if [ ! -f "$dockerdir/$dockerfile" ]; then
Chris@1539 25 echo "No matching docker file $dockerfile found in $dockerdir"
Chris@1539 26 exit 1
Chris@1539 27 fi
Chris@1539 28
Chris@1539 29 dockertag="cannam/sonic-visualiser-$platform"
Chris@1539 30
Chris@1539 31 sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir"
Chris@1539 32
Chris@1539 33 outdir="$dockerdir/output"
Chris@1539 34 mkdir -p "$outdir"
Chris@1539 35
Chris@1539 36 container=$(sudo docker create "$dockertag")
Chris@1539 37 sudo docker cp "$container":output.tar "$outdir"
Chris@1539 38 sudo docker rm "$container"
Chris@1539 39
Chris@1539 40 ( cd "$outdir" ; tar xf output.tar && rm -f output.tar )
Chris@1539 41
Chris@1539 42 echo
Chris@1539 43 echo "Done, output directory contains:"
Chris@1539 44 ls -ltr "$outdir"