Skip to content

Commit

Permalink
Remove build dirs from docker image to keep the layers small (#5243)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
michaelarnauts authored and balloob committed Jan 14, 2017
1 parent 7ed8330 commit d4eabaf
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 40 deletions.
21 changes: 4 additions & 17 deletions Dockerfile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
50 changes: 50 additions & 0 deletions 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/

28 changes: 6 additions & 22 deletions virtualization/Docker/Dockerfile.dev
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d4eabaf

Please sign in to comment.