annotate build/docker/build.sh @ 491:124752918a1b vamp-plugin-sdk-v2.7

Add Docker build scripts
author Chris Cannam
date Fri, 24 Feb 2017 15:45:50 +0000
parents
children
rev   line source
Chris@491 1 #!/bin/bash
Chris@491 2
Chris@491 3 dockerdir=./build/docker
Chris@491 4 if [ ! -d "$dockerdir" ]; then
Chris@491 5 echo "Run this script from the build root"
Chris@491 6 exit 2
Chris@491 7 fi
Chris@491 8
Chris@491 9 version="$1"
Chris@491 10 platform="$2"
Chris@491 11
Chris@491 12 if [ -z "$platform" ] || [ -z "$version" ] || [ -n "$3" ]; then
Chris@491 13 echo "Usage: $0 <version> <platform>"
Chris@491 14 echo "where <platform> matches the suffix of the Docker file, e.g. ubuntu1604"
Chris@491 15 exit 2
Chris@491 16 fi
Chris@491 17
Chris@491 18 set -eu
Chris@491 19
Chris@491 20 echo "Building for version $version, platform $platform"
Chris@491 21 dockerfile="Dockerfile_v${version}_${platform}"
Chris@491 22
Chris@491 23 if [ ! -f "$dockerdir/$dockerfile" ]; then
Chris@491 24 echo "No matching docker file $dockerfile found in $dockerdir"
Chris@491 25 exit 1
Chris@491 26 fi
Chris@491 27
Chris@491 28 dockertag="cannam/vamp-plugin-sdk-$platform"
Chris@491 29
Chris@491 30 sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir"
Chris@491 31
Chris@491 32 outdir="$dockerdir/output"
Chris@491 33 mkdir -p "$outdir"
Chris@491 34
Chris@491 35 container=$(sudo docker create "$dockertag")
Chris@491 36 sudo docker cp "$container":output.tar "$outdir"
Chris@491 37 sudo docker rm "$container"
Chris@491 38
Chris@491 39 ( cd "$outdir" ; tar xf output.tar && rm -f output.tar )
Chris@491 40
Chris@491 41 echo
Chris@491 42 echo "Done, output directory contains:"
Chris@491 43 ls -ltr "$outdir"