diff --git a/Dockerfile b/Dockerfile index 0337c800b15..8c7ab8a9039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ MAINTAINER Paulus Schoutsen #ENV INSTALL_TELLSTICK no #ENV INSTALL_OPENALPR no #ENV INSTALL_FFMPEG no +#ENV INSTALL_OPENZWAVE no +#ENV INSTALL_LIBCEC no #ENV INSTALL_PHANTOMJS no VOLUME /config @@ -13,8 +15,8 @@ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Copy build scripts -COPY script/setup_docker_prereqs script/build_python_openzwave script/build_libcec script/install_phantomjs script/ -RUN script/setup_docker_prereqs +COPY virtualization/Docker/ virtualization/Docker/ +RUN virtualization/Docker/setup_docker_prereqs # Install hass component dependencies COPY requirements_all.txt requirements_all.txt @@ -24,4 +26,4 @@ RUN pip3 install --no-cache-dir -r requirements_all.txt && \ # Copy source COPY . . -CMD [ "python", "-m", "homeassistant", "--config", "/config" ] +CMD [ "python", "-m", "homeassistant", "--config", "/config" ] \ No newline at end of file diff --git a/script/setup_docker_prereqs b/script/setup_docker_prereqs deleted file mode 100755 index 1c189410939..00000000000 --- a/script/setup_docker_prereqs +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# Install requirements and build dependencies for Home Assinstant in Docker. - -INSTALL_TELLSTICK="${INSTALL_TELLSTICK:-yes}" -INSTALL_OPENALPR="${INSTALL_OPENALPR:-yes}" -INSTALL_FFMPEG="${INSTALL_FFMPEG:-yes}" -INSTALL_PHANTOMJS="${INSTALL_PHANTOMJS:-yes}" - -# Required debian packages for running hass or components -PACKAGES=( - # build-essential is required for python pillow module on non-x86_64 arch - build-essential - # libxrandr-dev is required for openalpr - libxrandr-dev - # homeassistant.components.device_tracker.nmap_tracker - nmap net-tools libcurl3-dev - # homeassistant.components.device_tracker.bluetooth_tracker - bluetooth libglib2.0-dev libbluetooth-dev -) - -# Required debian packages for building dependencies -PACKAGES_DEV=( - cmake git - # python-openzwave - cython3 libudev-dev - # libcec - swig -) - -install_tellstick () { - TELLSTICK_PACKAGES=( - # homeassistant.components.tellstick - libtelldus-core2 - ) - - # Add Tellstick repository - echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list.d/telldus.list - wget -qO - http://download.telldus.se/debian/telldus-public.key | apt-key add - - - apt-get update - apt-get install -y --no-install-recommends ${TELLSTICK_PACKAGES[@]} -} - -install_openalpr () { - OPENALPR_PACKAGES=( - # homeassistant.components.image_processing.openalpr_local - libopencv-dev libtesseract-dev libleptonica-dev liblog4cplus-dev - ) - apt-get install -y --no-install-recommends ${OPENALPR_PACKAGES[@]} - # Clone the latest code from GitHub - git clone https://github.com/openalpr/openalpr.git /usr/local/src/openalpr - # Setup the build directory - cd /usr/local/src/openalpr/src - mkdir -p build - cd build - # Setup the compile environment - cmake -DWITH_TEST=FALSE -DWITH_BINDING_JAVA=FALSE --DWITH_BINDING_PYTHON=FALSE --DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. - # compile the library - make - # Install the binaries/libraries to your local system (prefix is /usr/local) - make install -} - -install_ffmpeg () { - apt-get install -y --no-install-recommends -t jessie-backports ffmpeg -} - -# Stop on errors -set -e - -cd "$(dirname "$0")/.." - -# Add jessie-backports -echo "Adding jessie-backports" -echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list - -# Install packages -echo "Updating Apt repositories" -apt-get update -echo "Installing packages" -apt-get install -y --no-install-recommends ${PACKAGES[@]} ${PACKAGES_DEV[@]} - -if [ "$INSTALL_TELLSTICK" == "yes" ]; then - echo "Installing tellstick" - install_tellstick -fi - -if [ "$INSTALL_OPENALPR" == "yes" ]; then - echo "Installing openalpr" - install_openalpr -fi - -if [ "$INSTALL_FFPMEG" == "yes" ]; then - echo "Installing ffmpeg" - install_ffmpeg -fi - -# Build and install openzwave -echo "Installing python-openzwave" -/usr/src/app/script/build_python_openzwave -mkdir -p /usr/local/share/python-openzwave -cp -R /usr/src/app/build/python-openzwave/openzwave/config /usr/local/share/python-openzwave/config - -# Build and install libcec -echo "Installing libcec" -/usr/src/app/script/build_libcec - -if [ "$INSTALL_PHANTOMJS" == "yes" ]; then - # Install phantomjs - script/install_phantomjs -fi - -# Remove packages -echo "Removing dev packages" -apt-get remove -y --purge ${PACKAGES_DEV[@]} -apt-get -y --purge autoremove - -# Cleanup -apt-get clean -rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* build/ - diff --git a/virtualization/Docker/Dockerfile.dev b/virtualization/Docker/Dockerfile.dev index 7968df25b69..4c75db36acc 100644 --- a/virtualization/Docker/Dockerfile.dev +++ b/virtualization/Docker/Dockerfile.dev @@ -5,14 +5,22 @@ FROM python:3.5 MAINTAINER Paulus Schoutsen +# Uncomment any of the following lines to disable the installation. +#ENV INSTALL_TELLSTICK no +#ENV INSTALL_OPENALPR no +#ENV INSTALL_FFMPEG no +#ENV INSTALL_OPENZWAVE no +#ENV INSTALL_LIBCEC no +#ENV INSTALL_PHANTOMJS no + VOLUME /config RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Copy build scripts -COPY script/setup_docker_prereqs script/build_python_openzwave script/build_libcec script/ -RUN script/setup_docker_prereqs +COPY virtualization/Docker/ virtualization/Docker/ +RUN virtualization/Docker/setup_docker_prereqs # Install hass component dependencies COPY requirements_all.txt requirements_all.txt @@ -40,4 +48,4 @@ RUN tox -e py35 --notest # Copy source COPY . . -CMD [ "python", "-m", "homeassistant", "--config", "/config" ] +CMD [ "python", "-m", "homeassistant", "--config", "/config" ] \ No newline at end of file diff --git a/virtualization/Docker/scripts/ffmpeg b/virtualization/Docker/scripts/ffmpeg new file mode 100755 index 00000000000..81b9ce694f9 --- /dev/null +++ b/virtualization/Docker/scripts/ffmpeg @@ -0,0 +1,16 @@ +#!/bin/bash +# Sets up ffmpeg. + +# Stop on errors +set -e + +PACKAGES=( + ffmpeg +) + +# Add jessie-backports +echo "Adding jessie-backports" +echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list +apt-get update + +apt-get install -y --no-install-recommends -t jessie-backports ${PACKAGES[@]} \ No newline at end of file diff --git a/script/build_libcec b/virtualization/Docker/scripts/libcec similarity index 94% rename from script/build_libcec rename to virtualization/Docker/scripts/libcec index fcac8e6f22c..44e90c40030 100755 --- a/script/build_libcec +++ b/virtualization/Docker/scripts/libcec @@ -1,5 +1,5 @@ #!/bin/sh -# Sets up and builds libcec to be used with Home Assistant. +# Sets up libcec. # Dependencies that need to be installed: # apt-get install cmake libudev-dev libxrandr-dev swig @@ -44,4 +44,4 @@ git submodule update --init src/platform make make install ldconfig -) +) \ No newline at end of file diff --git a/virtualization/Docker/scripts/openalpr b/virtualization/Docker/scripts/openalpr new file mode 100755 index 00000000000..ffecc864914 --- /dev/null +++ b/virtualization/Docker/scripts/openalpr @@ -0,0 +1,29 @@ +#!/bin/bash +# Sets up openalpr. + +# Stop on errors +set -e + +PACKAGES=( + # homeassistant.components.image_processing.openalpr_local + libopencv-dev libtesseract-dev libleptonica-dev liblog4cplus-dev +) + +apt-get install -y --no-install-recommends ${PACKAGES[@]} + +# Clone the latest code from GitHub +git clone https://github.com/openalpr/openalpr.git /usr/local/src/openalpr + +# Setup the build directory +cd /usr/local/src/openalpr/src +mkdir -p build +cd build + +# Setup the compile environment +cmake -DWITH_TEST=FALSE -DWITH_BINDING_JAVA=FALSE --DWITH_BINDING_PYTHON=FALSE --DWITH_BINDING_GO=FALSE -DWITH_DAEMON=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. + +# compile the library +make + +# Install the binaries/libraries to your local system (prefix is /usr/local) +make install \ No newline at end of file diff --git a/script/install_phantomjs b/virtualization/Docker/scripts/phantomjs similarity index 83% rename from script/install_phantomjs rename to virtualization/Docker/scripts/phantomjs index 178dfad540e..7c1e1dd3536 100755 --- a/script/install_phantomjs +++ b/virtualization/Docker/scripts/phantomjs @@ -1,5 +1,5 @@ #!/bin/bash -# Sets up phantomjs to be used with Home Assistant. +# Sets up phantomjs. # Stop on errors set -e @@ -12,4 +12,4 @@ mkdir -p build && cd build curl -LSO https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 tar -xjf phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 mv phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin/phantomjs /usr/bin/phantomjs -/usr/bin/phantomjs -v +/usr/bin/phantomjs -v \ No newline at end of file diff --git a/script/build_python_openzwave b/virtualization/Docker/scripts/python_openzwave similarity index 82% rename from script/build_python_openzwave rename to virtualization/Docker/scripts/python_openzwave index db82fe08d8b..f4eb233e53c 100755 --- a/script/build_python_openzwave +++ b/virtualization/Docker/scripts/python_openzwave @@ -1,5 +1,5 @@ #!/bin/sh -# Sets up and builds python open zwave to be used with Home Assistant. +# Sets up python-openzwave. # Dependencies that need to be installed: # apt-get install cython3 libudev-dev python3-sphinx python3-setuptools @@ -27,3 +27,6 @@ git checkout python3 pip3 install --upgrade cython==0.24.1 PYTHON_EXEC=`which python3` make build PYTHON_EXEC=`which python3` make install + +mkdir -p /usr/local/share/python-openzwave +cp -R openzwave/config /usr/local/share/python-openzwave/config \ No newline at end of file diff --git a/virtualization/Docker/scripts/tellstick b/virtualization/Docker/scripts/tellstick new file mode 100755 index 00000000000..805e411f47b --- /dev/null +++ b/virtualization/Docker/scripts/tellstick @@ -0,0 +1,17 @@ +#!/bin/bash +# Sets up tellstick. + +# Stop on errors +set -e + +PACKAGES=( + # homeassistant.components.tellstick + libtelldus-core2 +) + +# Add Tellstick repository +echo "deb http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list.d/telldus.list +wget -qO - http://download.telldus.se/debian/telldus-public.key | apt-key add - + +apt-get update +apt-get install -y --no-install-recommends ${PACKAGES[@]} \ No newline at end of file diff --git a/virtualization/Docker/setup_docker_prereqs b/virtualization/Docker/setup_docker_prereqs new file mode 100755 index 00000000000..9a878b3abba --- /dev/null +++ b/virtualization/Docker/setup_docker_prereqs @@ -0,0 +1,69 @@ +#!/bin/bash +# Install requirements and build dependencies for Home Assinstant in Docker. + +# Stop on errors +set -e + +INSTALL_TELLSTICK="${INSTALL_TELLSTICK:-yes}" +INSTALL_OPENALPR="${INSTALL_OPENALPR:-yes}" +INSTALL_FFMPEG="${INSTALL_FFMPEG:-yes}" +INSTALL_OPENZWAVE="${INSTALL_OPENZWAVE:-yes}" +INSTALL_LIBCEC="${INSTALL_LIBCEC:-yes}" +INSTALL_PHANTOMJS="${INSTALL_PHANTOMJS:-yes}" + +# Required debian packages for running hass or components +PACKAGES=( + # build-essential is required for python pillow module on non-x86_64 arch + build-essential + # homeassistant.components.image_processing.openalpr_local + libxrandr-dev + # homeassistant.components.device_tracker.nmap_tracker + nmap net-tools libcurl3-dev + # homeassistant.components.device_tracker.bluetooth_tracker + bluetooth libglib2.0-dev libbluetooth-dev +) + +# Required debian packages for building dependencies +PACKAGES_DEV=( + cmake git + # python-openzwave + cython3 libudev-dev + # libcec + swig +) + +# Install packages +apt-get update +apt-get install -y --no-install-recommends ${PACKAGES[@]} ${PACKAGES_DEV[@]} + +if [ "$INSTALL_TELLSTICK" == "yes" ]; then + virtualization/Docker/scripts/tellstick +fi + +if [ "$INSTALL_OPENALPR" == "yes" ]; then + virtualization/Docker/scripts/openalpr +fi + +if [ "$INSTALL_FFMPEG" == "yes" ]; then + virtualization/Docker/scripts/ffmpeg +fi + +if [ "$INSTALL_OPENZWAVE" == "yes" ]; then + virtualization/Docker/scripts/python_openzwave +fi + +if [ "$INSTALL_LIBCEC" == "yes" ]; then + virtualization/Docker/scripts/libcec +fi + +if [ "$INSTALL_PHANTOMJS" == "yes" ]; then + virtualization/Docker/scripts/phantomjs +fi + +# Remove packages +apt-get remove -y --purge ${PACKAGES_DEV[@]} +apt-get -y --purge autoremove + +# Cleanup +apt-get clean +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* build/ \ No newline at end of file