diff deploy/linux/docker/build.sh @ 300:7dd6795af5e6

Start updating build stuff for 1.5
author Chris Cannam
date Thu, 25 May 2017 14:17:53 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/linux/docker/build.sh	Thu May 25 14:17:53 2017 +0100
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+version=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h | sed 's/-//g')
+
+dockerdir=./deploy/linux/docker
+if [ ! -d "$dockerdir" ]; then
+    echo "Run this script from the build root"
+    exit 2
+fi
+
+platform="$1"
+
+if [ -z "$platform" ] || [ -n "$2" ]; then
+    echo "Usage: $0 <platform>"
+    echo "where <platform> matches the suffix of the Docker file, e.g. ubuntu1604"
+    exit 2
+fi
+
+set -eu
+
+echo "Building for version $version, platform $platform"
+dockerfile="Dockerfile_v${version}_${platform}"
+
+if [ ! -f "$dockerdir/$dockerfile" ]; then
+    echo "No matching docker file $dockerfile found in $dockerdir"
+    exit 1
+fi
+
+dockertag="cannam/sonic-annotator-$platform"
+
+sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir"
+
+outdir="$dockerdir/output"
+mkdir -p "$outdir"
+
+container=$(sudo docker create "$dockertag")
+sudo docker cp "$container":output.tar "$outdir"
+sudo docker rm "$container"
+
+( cd "$outdir" ; tar xf output.tar && rm -f output.tar )
+
+echo
+echo "Done, output directory contains:"
+ls -ltr "$outdir"