Development in Docker docs

Hi devs,

I don’t see any doco on using the included Dockerfiles - I messed about trying to build some stuff yesterday for a few hours but didn’t figure it all out. Conventionally, open source projects include a block on the “contributing” page saying something like:

EDIT2: To be clear I’m talking about this Dockerfile and the other Dockerfile.dev

To build this project for local development run:
docker build -f Dockerfile.dev -t yourname/home-assistant:dev .

To build for release (typically run by a pipeline off master):
docker build -f Dockerfile --build-arg BUILD_FROM=somebaseimage -t homeassistant/home-assistant:dev.

Which would make it rather easy for me to simply copy/paste and have a working image.

I think rather than building locally I maybe ought to pull the built image from dockerhub and mount my code into it - but obviously one can have dependency problems with that approach.

Please let me know how this is supposed to work - I’ll be happy to write a basic doco to be included at Miscellaneous | Home Assistant Developer Docs

EDIT: the doc should probably include something about the purpose of GitHub - home-assistant/wheels: Build wheels for Home Assistant for the non-python folks coming to the project

I suppose you know about https://github.com/home-assistant/docker
Seems straightforward to me. What were your issues?

This repo also has no docs.

My issue is simple:

What is the canonical way to do HA development in docker?

Dockerfile.dev is linked from .devcontainer. It’s a specialized container for core development via vscode.
see https://developers.home-assistant.io/docs/development_environment/#developing-with-visual-studio-code--devcontainer

The “plain” Dockerfile, idk. Maybe related to CI/CD, but I doubt it is meant to be used “as-is”

Documenting here a somewhat hacky way to test an upgrade to a dependent library, in docker. I welcome better ways to do it!

Assuming I’ve got the latest 2.1.1 cloned into local directory python-snapcast.

Adding a custom dockerfile (Dockerfile.ha):

FROM homeassistant/home-assistant:0.115.2
COPY python-snapcast /config/python-snapcast
RUN pip uninstall --yes snapcast && \
	pip install -e /config/python-snapcast && \
	pip show snapcast

Then docker build:

docker build -f Dockerfile.ha -t mafrosis/home-assistant:0.115.2 .

All very reasonable at this point. It gets hacky because you need to override the component’s version number in its manifest file - or HA decides to reinstall the previous version at startup. I haven’t found a simpler way to disable this behaviour:

> cat snapcast-2.1.1-manifest.json
{
  "domain": "snapcast",
  "name": "Snapcast",
  "documentation": "https://www.home-assistant.io/integrations/snapcast",
  "codeowners": []
}

The run command looks like:

docker run --rm -it \
  -v $(pwd)/snapcast-2.1.1-manifest.json:/usr/src/homeassistant/homeassistant/components/snapcast/manifest.json \
  -v $(pwd):/config \
  -p 8123:8123 \
  mafrosis/home-assistant:0.115.2