Development Docker Image?

Hey everyone

Looking to start playing around and creating some components for Home Assistant. I’ve currently got HASS running via a docker image on my Synology NAS.

Just wondering if there is a Docker image for development? That installs all the git hooks, test suites etc that I can run my own HASS fork from.

Thanks!

1 Like

Hey,

I’ve been doing the following:

Build my development image locally using the default Dockerfile.

docker build -t jacobtomlinson/home-assistant:dev .

Then I created a development file Dockerfile.dev which is based on the default and adds the test suite.

FROM jacobtomlinson/home-assistant:dev
MAINTAINER Jacob Tomlinson <[email protected]>

RUN apt-get update && \
    apt-get install -y --no-install-recommends locales-all && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pip3 install --no-cache-dir tox

CMD [ "tox" ]

Once that is built I run that container but use a volume to add my development source in.

docker build -t jacobtomlinson/home-assistant-dev:dev -f Dockerfile.dev .
docker run -p 8123:8123 -v $(pwd):/usr/src/app jacobtomlinson/home-assistant-dev:dev

I like the model of basing the dev container off the production container as it leaves the production one clean. There are a few drawbacks to this approach including not capturing dependancy changes, so I recommend periodically rebuilding both containers during development.

3 Likes

That is beautiful! Will be trying this out!

Cheers

1 Like

Thanks for sharing your development setup, has come in handy to set up mine.

I also wanted to share how you can quickly run individual tests with the development docker image, so people new to tox are quickly up and running without having to run everything.

Execute the docker image but with the bash command instead.

docker run -p 8123:8123 -v $(pwd):/usr/src/app jacobtomlinson/home-assistant-dev:dev /bin/bash

Then you can run the individual tests for lets say the ddwrt device tracker

flake8 homeassistant/components/device_tracker/ddwrt.py
tox -e py35 -- tests/components/device_tracker/test_ddwrt.py

For these two commands (listed on Testing your code) I haven’t found a fast alternative working in docker

pylint homeassistant/components/device_tracker/ddwrt.py
pydocstyle homeassistant/components/device_tracker/ddwrt.py
2 Likes