diff --git a/Dockerfile b/Dockerfile index 342b62e6ec1..7522ca9cb64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,24 +6,11 @@ VOLUME /config RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -RUN pip3 install --no-cache-dir colorlog cython - -# For the nmap tracker, bluetooth tracker, Z-Wave, tellstick -RUN 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 nmap net-tools cython3 libudev-dev sudo libglib2.0-dev bluetooth libbluetooth-dev \ - libtelldus-core2 cmake libxrandr-dev swig && \ - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -COPY script/build_python_openzwave script/build_python_openzwave -RUN script/build_python_openzwave && \ - mkdir -p /usr/local/share/python-openzwave && \ - ln -sf /usr/src/app/build/python-openzwave/openzwave/config /usr/local/share/python-openzwave/config - -COPY script/build_libcec script/build_libcec -RUN script/build_libcec +# Copy build scripts +COPY script/setup_docker_prereqs script/build_python_openzwave script/build_libcec script/ +RUN script/setup_docker_prereqs +# Install hass component dependencies COPY requirements_all.txt requirements_all.txt RUN pip3 install --no-cache-dir -r requirements_all.txt && \ pip3 install --no-cache-dir mysqlclient psycopg2 uvloop diff --git a/script/build_libcec b/script/build_libcec index ad7e62c50a6..1c30d634437 100755 --- a/script/build_libcec +++ b/script/build_libcec @@ -1,7 +1,7 @@ #!/bin/sh # Sets up and builds libcec to be used with Home Assistant. # Dependencies that need to be installed: -# apt-get install cmake libudev-dev libxrandr-dev python-dev swig +# apt-get install cmake libudev-dev libxrandr-dev swig # Stop on errors set -e diff --git a/script/setup_docker_prereqs b/script/setup_docker_prereqs new file mode 100755 index 00000000000..a7c7e493f27 --- /dev/null +++ b/script/setup_docker_prereqs @@ -0,0 +1,50 @@ +#!/bin/bash +# Install requirements and build dependencies for Home Assinstant in Docker. + +# Required debian packages for running hass or components +PACKAGES=( + # homeassistant.components.device_tracker.nmap_tracker + nmap net-tools + # homeassistant.components.device_tracker.bluetooth_tracker + bluetooth libglib2.0-dev libbluetooth-dev + # homeassistant.components.tellstick + libtelldus-core2 +) + +# Required debian packages for building dependencies +PACKAGES_DEV=( + # python-openzwave + cython3 libudev-dev + # libcec + cmake swig libxrandr-dev +) + +# Stop on errors +set -e + +cd "$(dirname "$0")/.." + +# 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 - + +# Install packages +apt-get update +apt-get install -y --no-install-recommends ${PACKAGES[@]} ${PACKAGES_DEV[@]} + +# Build and install openzwave +script/build_python_openzwave +mkdir -p /usr/local/share/python-openzwave +ln -sf /usr/src/app/build/python-openzwave/openzwave/config /usr/local/share/python-openzwave/config + +# Build and install libcec +script/build_libcec + +# 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/ + diff --git a/virtualization/Docker/Dockerfile.dev b/virtualization/Docker/Dockerfile.dev index f86a0e3de7f..7968df25b69 100644 --- a/virtualization/Docker/Dockerfile.dev +++ b/virtualization/Docker/Dockerfile.dev @@ -10,24 +10,11 @@ VOLUME /config RUN mkdir -p /usr/src/app WORKDIR /usr/src/app -RUN pip3 install --no-cache-dir colorlog cython - -# For the nmap tracker, bluetooth tracker, Z-Wave, tellstick -RUN 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 nmap net-tools cython3 libudev-dev sudo libglib2.0-dev bluetooth libbluetooth-dev \ - libtelldus-core2 cmake libxrandr-dev swig && \ - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -COPY script/build_python_openzwave script/build_python_openzwave -RUN script/build_python_openzwave && \ - mkdir -p /usr/local/share/python-openzwave && \ - ln -sf /usr/src/app/build/python-openzwave/openzwave/config /usr/local/share/python-openzwave/config - -COPY script/build_libcec script/build_libcec -RUN script/build_libcec +# Copy build scripts +COPY script/setup_docker_prereqs script/build_python_openzwave script/build_libcec script/ +RUN script/setup_docker_prereqs +# Install hass component dependencies COPY requirements_all.txt requirements_all.txt RUN pip3 install --no-cache-dir -r requirements_all.txt && \ pip3 install --no-cache-dir mysqlclient psycopg2 uvloop @@ -42,13 +29,10 @@ RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - && \ RUN pip3 install --no-cache-dir tox # Copy over everything required to run tox -COPY requirements_test.txt . -COPY setup.cfg . -COPY setup.py . -COPY tox.ini . +COPY requirements_test.txt setup.cfg setup.py tox.ini ./ COPY homeassistant/const.py homeassistant/const.py -# Get all dependencies +# Prefetch dependencies for tox RUN tox -e py35 --notest # END: Development additions