view SCRIPTS/dockerbuild.sh @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 3a8658f7e0b7
children
line wrap: on
line source
#!/bin/bash
#
# Docker required!

if [ -z "$1" ] || [ -z "$2" ]; then
    echo "Usage: $0 <repo> <repo-revision-id>"
    exit 2
fi

platform=ubuntu1604
dockerfile=SCRIPTS/Dockerfile_$platform

mkdir -p "PACKAGES/$platform"

if [ ! -f "$dockerfile.in" ]; then
    echo "Docker file source $dockerfile.in not found (are we in the right directory?"
    exit 1
fi

set -eu

repo="$1"
repo_revision="$2"

current=$(hg id | awk '{ print $1; }')

case "$current" in
    *+) echo "WARNING: Current working copy has been modified - build will check out the last commit, which must perforce be different";;
    *);;
esac

current=${current%%+}

cat "$dockerfile.in" \
    | perl -p -e 's/\[\[REVISION\]\]/'"$current"'/' \
    | perl -p -e 's/\[\[REPO\]\]/'"$repo"'/' \
    | perl -p -e 's/\[\[REPOREVISION\]\]/'"$repo_revision"'/' \
           > "$dockerfile"

dockertag="cannam/vamp-build-and-test-$current"

sudo docker build -t "$dockertag" -f "$dockerfile" SCRIPTS

container=$(sudo docker create "$dockertag")
sudo docker cp "$container":vamp-build-and-test/PACKAGES/linux64/ "PACKAGES/$platform"/
sudo docker rm "$container"

echo "Done!"