Mercurial > hg > sonic-annotator
annotate deploy/linux/docker/build.sh @ 318:3d129db143f4
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Tue, 15 May 2018 15:30:38 +0100 |
parents | 7dd6795af5e6 |
children |
rev | line source |
---|---|
Chris@300 | 1 #!/bin/bash |
Chris@300 | 2 |
Chris@300 | 3 version=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h | sed 's/-//g') |
Chris@300 | 4 |
Chris@300 | 5 dockerdir=./deploy/linux/docker |
Chris@300 | 6 if [ ! -d "$dockerdir" ]; then |
Chris@300 | 7 echo "Run this script from the build root" |
Chris@300 | 8 exit 2 |
Chris@300 | 9 fi |
Chris@300 | 10 |
Chris@300 | 11 platform="$1" |
Chris@300 | 12 |
Chris@300 | 13 if [ -z "$platform" ] || [ -n "$2" ]; then |
Chris@300 | 14 echo "Usage: $0 <platform>" |
Chris@300 | 15 echo "where <platform> matches the suffix of the Docker file, e.g. ubuntu1604" |
Chris@300 | 16 exit 2 |
Chris@300 | 17 fi |
Chris@300 | 18 |
Chris@300 | 19 set -eu |
Chris@300 | 20 |
Chris@300 | 21 echo "Building for version $version, platform $platform" |
Chris@300 | 22 dockerfile="Dockerfile_v${version}_${platform}" |
Chris@300 | 23 |
Chris@300 | 24 if [ ! -f "$dockerdir/$dockerfile" ]; then |
Chris@300 | 25 echo "No matching docker file $dockerfile found in $dockerdir" |
Chris@300 | 26 exit 1 |
Chris@300 | 27 fi |
Chris@300 | 28 |
Chris@300 | 29 dockertag="cannam/sonic-annotator-$platform" |
Chris@300 | 30 |
Chris@300 | 31 sudo docker build -t "$dockertag" -f "$dockerdir/$dockerfile" "$dockerdir" |
Chris@300 | 32 |
Chris@300 | 33 outdir="$dockerdir/output" |
Chris@300 | 34 mkdir -p "$outdir" |
Chris@300 | 35 |
Chris@300 | 36 container=$(sudo docker create "$dockertag") |
Chris@300 | 37 sudo docker cp "$container":output.tar "$outdir" |
Chris@300 | 38 sudo docker rm "$container" |
Chris@300 | 39 |
Chris@300 | 40 ( cd "$outdir" ; tar xf output.tar && rm -f output.tar ) |
Chris@300 | 41 |
Chris@300 | 42 echo |
Chris@300 | 43 echo "Done, output directory contains:" |
Chris@300 | 44 ls -ltr "$outdir" |