Add homeassistant machine builds

This commit is contained in:
Pascal Vizeli 2017-06-16 15:21:10 +02:00
parent e126ce8476
commit 7e4001d4ab
9 changed files with 38 additions and 157 deletions

View file

@ -3,7 +3,7 @@ set -e
BUILD_CONTAINER_NAME=homeassistant-build-$$
DOCKER_PUSH="false"
DOCKER_CACHE="true"
DOCKER_CACHE="false"
DOCKER_HUB=homeassistant
cleanup() {
@ -38,8 +38,6 @@ Options:
Version/Tag/branch of HomeAssistant build.
-p, --push
Upload the build to docker hub.
-n, --no-cache
Disable build from cache
EOF
}
@ -66,9 +64,6 @@ while [[ $# -gt 0 ]]; do
-p|--push)
DOCKER_PUSH="true"
;;
-n|--no-cache)
DOCKER_CACHE="false"
;;
*)
echo "[WARNING] $0 : Argument '$1' unknown. Ignoring."
;;
@ -96,23 +91,6 @@ popd > /dev/null 2>&1
DOCKER_IMAGE=$DOCKER_HUB/$MACHINE-homeassistant
BUILD_DIR=${BUILD_DIR:=$SCRIPTPATH}
WORKSPACE=$BUILD_DIR/hass-$MACHINE
HASS_GIT=$WORKSPACE/homeassistant
# generate base image
case $MACHINE in
"raspberrypi1")
BASE_IMAGE="resin\/raspberry-pi-alpine:3.5"
;;
"raspberrypi2")
BASE_IMAGE="resin\/raspberry-pi2-alpine:3.5"
;;
"raspberrypi3")
BASE_IMAGE="resin\/raspberry-pi3-alpine:3.5"
;;
*)
BASE_IMAGE="resin\/${MACHINE}-alpine:3.5"
;;
esac
# setup docker
echo "[INFO] Setup docker for homeassistant"
@ -120,19 +98,9 @@ mkdir -p "$BUILD_DIR"
mkdir -p "$WORKSPACE"
echo "[INFO] load homeassistant"
cp ../../homeassistant/Dockerfile "$WORKSPACE/Dockerfile"
cp "../../homeassistant/machine/$MACHINE" "$WORKSPACE/Dockerfile"
sed -i "s/%%BASE_IMAGE%%/${BASE_IMAGE}/g" "$WORKSPACE/Dockerfile"
git clone --depth 1 -b "$DOCKER_TAG" https://github.com/home-assistant/home-assistant "$HASS_GIT" > /dev/null 2>&1
DOCKER_TAG="$(python3 "$HASS_GIT/setup.py" -V | sed -e "s:^\(.\...\)\.0$:\1:g" -e "s:^\(.\...\)\.0.dev0$:\1-dev:g")"
if [ -z "$DOCKER_TAG" ]; then
echo "[ERROR] Can't read homeassistant version!"
exit 1
fi
echo "LABEL io.hass.version=\"$DOCKER_TAG\" io.hass.type=\"homeassistant\" io.hass.machine=\"$MACHINE\"" >> "$WORKSPACE/Dockerfile"
sed -i "s/%%VERSION%%/${DOCKER_TAG}/g" "$WORKSPACE/Dockerfile"
echo "[INFO] prepare done for $DOCKER_IMAGE:$DOCKER_TAG"
# Run build