From 7e4001d4ab2f9c9a370389301a85e207c15bdce2 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 16 Jun 2017 15:21:10 +0200 Subject: [PATCH] Add homeassistant machine builds --- .../create_homeassistant_generic.sh | 5 + .../homeassistant/create_homeassistant.sh | 38 +----- homeassistant/Dockerfile | 122 ------------------ homeassistant/machine/intel-nuc | 5 + homeassistant/machine/qemux86 | 5 + homeassistant/machine/qemux86-64 | 5 + homeassistant/machine/raspberrypi | 5 + homeassistant/machine/raspberrypi2 | 5 + homeassistant/machine/raspberrypi3 | 5 + 9 files changed, 38 insertions(+), 157 deletions(-) delete mode 100644 homeassistant/Dockerfile create mode 100644 homeassistant/machine/intel-nuc create mode 100644 homeassistant/machine/qemux86 create mode 100644 homeassistant/machine/qemux86-64 create mode 100644 homeassistant/machine/raspberrypi create mode 100644 homeassistant/machine/raspberrypi2 create mode 100644 homeassistant/machine/raspberrypi3 diff --git a/build-scripts/homeassistant-generic/create_homeassistant_generic.sh b/build-scripts/homeassistant-generic/create_homeassistant_generic.sh index cfb31bf..1bbf8c1 100755 --- a/build-scripts/homeassistant-generic/create_homeassistant_generic.sh +++ b/build-scripts/homeassistant-generic/create_homeassistant_generic.sh @@ -78,6 +78,11 @@ if [ -z "$ARCH" ]; then help exit 1 fi +if [ -z "$DOCKER_TAG" ]; then + echo "[ERROR] please set a version!" + help + exit 1 +fi # Get the absolute script location pushd "$(dirname "$0")" > /dev/null 2>&1 diff --git a/build-scripts/homeassistant/create_homeassistant.sh b/build-scripts/homeassistant/create_homeassistant.sh index 4dc351e..ed139f2 100755 --- a/build-scripts/homeassistant/create_homeassistant.sh +++ b/build-scripts/homeassistant/create_homeassistant.sh @@ -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 diff --git a/homeassistant/Dockerfile b/homeassistant/Dockerfile deleted file mode 100644 index 5f59a52..0000000 --- a/homeassistant/Dockerfile +++ /dev/null @@ -1,122 +0,0 @@ -FROM %%BASE_IMAGE%% - -# Add env -ENV LANG C.UTF-8 - -# install core & build packages -RUN apk --no-cache add \ - python3 \ - python3-dev \ - tzdata \ - libuv \ - musl-dev \ - git \ - linux-headers \ - eudev-dev \ - libusb-dev \ - libffi-dev \ - libjpeg-turbo-dev \ - libpng-dev \ - libxml2-dev \ - libxslt-dev \ - jpeg-dev \ - tiff-dev \ - freetype-dev \ - autoconf \ - automake \ - libtool \ - cmake \ - make \ - g++ \ - gcc \ - ncurses-dev - -## -# install component packages -RUN apk --no-cache add \ - ffmpeg \ - nmap \ - libcec \ - net-tools \ - mariadb-dev \ - postgresql-dev \ - bluez-dev \ - bluez \ - curl \ - libsodium-dev \ - openssh-client - -#### -## Build library -WORKDIR /usr/src/ -RUN ln -s /usr/include/locale.h /usr/include/xlocale.h - -# ssocr -RUN apk --no-cache add imlib2-dev \ - && git clone --depth 1 https://github.com/auerswal/ssocr \ - && cd ssocr \ - && make \ - && make install \ - && rm -rf /usr/src/ssocr - -# OpenCV / scipy -ENV PYTHONPATH /usr/local/lib/python3.5/site-packages -RUN apk --no-cache add lapack-dev gfortran \ - && pip3 install --no-cache-dir numpy==1.12.0 scipy \ - && git clone --depth 1 -b 3.2.0 https://github.com/opencv/opencv \ - && cd opencv \ - && mkdir -p build \ - && cd build \ - && cmake ../ -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF \ - && make \ - && make install \ - && rm -rf /usr/src/opencv - -# OpenAlpr -RUN apk --no-cache add tesseract-ocr-dev \ - && git clone --depth 1 -b REL_1_2_0 https://github.com/log4cplus/log4cplus \ - && cd log4cplus \ - && ./configure \ - && sed -i "s/1\.14/1.15/g" aclocal.m4 \ - && sed -i "s/1\.14/1.15/g" Makefile.in \ - && make \ - && make install \ - && rm -rf /usr/src/log4cplus -RUN git clone --depth 1 -b v2.3.0 https://github.com/openalpr/openalpr \ - && cd openalpr/src \ - && mkdir -p build \ - && cd build \ - && cmake ../ -DWITH_TESTS=FALSE -DWITH_BINDING_JAVA=FALSE -DWITH_BINDING_PYTHON=FALSE -DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local \ - && make \ - && make install \ - && rm -rf /usr/src/openalpr - -# libcoap -RUN git clone --depth 1 --recursive -b dtls https://github.com/home-assistant/libcoap \ - && cd libcoap \ - && grep -r -l u_int8_t * | xargs sed -i "s/u_int8_t/unsigned char/g" \ - && grep -r -l u_int32_t * | xargs sed -i "s/u_int32_t/unsigned int/g" \ - && grep -r -l u_int64_t * | xargs sed -i "s/u_int64_t/unsigned long long/g" \ - && grep -r -l "time_t coap_time_t" * | xargs sed -i "s/time_t coap_time_t/unsigned long long coap_time_t/g" \ - && ./autogen.sh \ - && ./configure --disable-documentation --disable-shared --without-debug CFLAGS="-D COAP_DEBUG_FD=stderr" \ - && make \ - && make install \ - && rm -rf /usr/src/libcoap - -#### -## install pip module for component -COPY homeassistant/ homeassistant -RUN pip3 install --no-cache-dir -r homeassistant/requirements_all.txt \ - && pip3 install --no-cache-dir mysqlclient psycopg2 pybluez \ - && pip3 install --no-cache-dir cchardet uvloop \ - && pip3 install --no-cache-dir /usr/src/homeassistant \ - && rm -r homeassistant - -# Install and update certificate -RUN apk --no-cache add ca-certificates \ - && update-ca-certificates - -# Run hass -WORKDIR /config -CMD [ "python3", "-m", "homeassistant", "--config", "/config" ] diff --git a/homeassistant/machine/intel-nuc b/homeassistant/machine/intel-nuc new file mode 100644 index 0000000..8c4abbe --- /dev/null +++ b/homeassistant/machine/intel-nuc @@ -0,0 +1,5 @@ +FROM homeassistant/amd64-homeassistant:%%VERSION%% + +LABEL io.hass.machine intel-nuc + +RUN apk --no-cache add usbutils diff --git a/homeassistant/machine/qemux86 b/homeassistant/machine/qemux86 new file mode 100644 index 0000000..3b24fbb --- /dev/null +++ b/homeassistant/machine/qemux86 @@ -0,0 +1,5 @@ +FROM homeassistant/i386-homeassistant:%%VERSION%% + +LABEL io.hass.machine qemux86 + +RUN apk --no-cache add usbutils diff --git a/homeassistant/machine/qemux86-64 b/homeassistant/machine/qemux86-64 new file mode 100644 index 0000000..de6bc94 --- /dev/null +++ b/homeassistant/machine/qemux86-64 @@ -0,0 +1,5 @@ +FROM homeassistant/amd64-homeassistant:%%VERSION%% + +LABEL io.hass.machine qemux86-64 + +RUN apk --no-cache add usbutils diff --git a/homeassistant/machine/raspberrypi b/homeassistant/machine/raspberrypi new file mode 100644 index 0000000..b414905 --- /dev/null +++ b/homeassistant/machine/raspberrypi @@ -0,0 +1,5 @@ +FROM homeassistant/armhf-homeassistant:%%VERSION%% + +LABEL io.hass.machine raspberrypi + +RUN apk --no-cache add raspberrypi raspberrypi-libs raspberrypi-dev usbutils diff --git a/homeassistant/machine/raspberrypi2 b/homeassistant/machine/raspberrypi2 new file mode 100644 index 0000000..0e76b2c --- /dev/null +++ b/homeassistant/machine/raspberrypi2 @@ -0,0 +1,5 @@ +FROM homeassistant/armhf-homeassistant:%%VERSION%% + +LABEL io.hass.machine raspberrypi2 + +RUN apk --no-cache add raspberrypi raspberrypi-libs raspberrypi-dev usbutils diff --git a/homeassistant/machine/raspberrypi3 b/homeassistant/machine/raspberrypi3 new file mode 100644 index 0000000..40227e5 --- /dev/null +++ b/homeassistant/machine/raspberrypi3 @@ -0,0 +1,5 @@ +FROM homeassistant/armhf-homeassistant:%%VERSION%% + +LABEL io.hass.machine raspberrypi3 + +RUN apk --no-cache add raspberrypi raspberrypi-libs raspberrypi-dev usbutils