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

@ -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

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

View file

@ -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" ]

View file

@ -0,0 +1,5 @@
FROM homeassistant/amd64-homeassistant:%%VERSION%%
LABEL io.hass.machine intel-nuc
RUN apk --no-cache add usbutils

View file

@ -0,0 +1,5 @@
FROM homeassistant/i386-homeassistant:%%VERSION%%
LABEL io.hass.machine qemux86
RUN apk --no-cache add usbutils

View file

@ -0,0 +1,5 @@
FROM homeassistant/amd64-homeassistant:%%VERSION%%
LABEL io.hass.machine qemux86-64
RUN apk --no-cache add usbutils

View file

@ -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

View file

@ -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

View file

@ -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