#!/bin/bash

DIR=$1

if [[ -z "$DIR" ]]; then
    echo "tests dir must be specified"
    exit 1
fi

git clone -b master https://github.com/mendersoftware/integration.git

mv integration $PWD/tests

go build -o $PWD/tests/mender-cli;

curl --fail "https://d1b0l86ne08fsf.cloudfront.net/mender-artifact/master/mender-artifact" \
    -o $DIR/mender-artifact

if [[ $? -ne 0 ]]; then
    echo "failed to download mender-artifact"
    exit 1
fi

chmod +x $DIR/mender-artifact

docker build -t testing $DIR
