Remove build dirs from docker image to keep the layers small (#5243)

* Remove build dirs from docker image to keep the layers small

* Create setup_docker_prereqs script to prepare docker env

* Add documentation for required packages, drop colorlog and cython in first step of Dockerfile since it will be installed later on anyway. Drop libglib2.0-dev and libbluetooth-dev

* Also remove early install of colorlog and cython in Dockerfile.dev

* Re-add libglib2.0-dev and libbluetooth-dev for Bluetooth LE
This commit is contained in:
Michaël Arnauts 2017-01-14 16:41:41 +01:00 committed by Paulus Schoutsen
parent 7ed83306ea
commit d4eabaf844
4 changed files with 61 additions and 40 deletions

View file

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

View file

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

50
script/setup_docker_prereqs Executable file
View file

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

View file

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