Dockerfile 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # https://hub.docker.com/r/homeassistant/home-assistant/tags
  2. # https://github.com/home-assistant/core/blob/0.109.3/azure-pipelines-release.yml#L76
  3. ARG HOME_ASSISTANT_VERSION=2021.7.2
  4. FROM homeassistant/home-assistant:$HOME_ASSISTANT_VERSION
  5. # Adafruit-DHT: no wheel available
  6. # https://pypi.org/project/Adafruit-DHT/1.4.0/#files
  7. # https://wheels.home-assistant.io/alpine-3.10/armv7/
  8. #> $ sudo docker run --rm homeassistant/home-assistant:0.104.3 pip freeze | grep -i adafruit
  9. #> starting version 3.2.8
  10. #> Adafruit-Blinka==1.2.1
  11. #> adafruit-circuitpython-busdevice==4.1.1
  12. #> adafruit-circuitpython-mcp230xx==1.1.2
  13. #> Adafruit-GPIO==1.0.3
  14. #> Adafruit-PCA9685==1.0.1
  15. #> Adafruit-PlatformDetect==1.4.5
  16. #> Adafruit-PureIO==1.0.4
  17. #> Adafruit-SHT31==1.0.2
  18. # but no 'Adafruit-DHT'
  19. # home-assistant/core v2021.5.0 replaced Adafruit-DHT with circuitpython
  20. # https://github.com/home-assistant/core/commit/d6c01cc0e60439ceb89df5feafc1bcb4e0892357
  21. # https://github.com/home-assistant/core/commit/c4a2dd5c3d91aea60f082d1ba2c253988b3b4c79
  22. # hadolint ignore=DL3018
  23. RUN apk add --no-cache \
  24. gcc \
  25. musl-dev \
  26. tini
  27. # not inherited:
  28. EXPOSE 8123/tcp
  29. # why do the home assistant maintainers run their containers as root?!
  30. RUN python3 -c 'import os; assert os.geteuid() == 0, "finally..."' \
  31. && find / -xdev -type f -perm /u+s -exec chmod -c u-s {} \; \
  32. && find / -xdev -type f -perm /g+s -exec chmod -c g-s {} \; \
  33. && adduser -D hass \
  34. && chown hass /config \
  35. && mkdir -p ~hass/.config/pip \
  36. && echo -e '[install]\nuser = yes' > ~hass/.config/pip/pip.conf
  37. VOLUME /config
  38. # > WARNING (MainThread) [matplotlib] Matplotlib created a temporary config/cache directory at /tmp/matplotlib-[...] \
  39. # > it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, \
  40. # > in particular to speed up the import of Matplotlib and to better support multiprocessing.
  41. ENV MPLCONFIGDIR=/config/matplotlib
  42. USER hass
  43. # > $ docker inspect --format '{{json .Config.Entrypoint}}' homeassistant/home-assistant:0.106.6
  44. # > ["/bin/entry.sh"]
  45. # > $ dockerinspect --format '{{json .Config.Cmd}}' homeassistant/home-assistant:0.106.6
  46. # > ["python3","-m","homeassistant","--config","/config"]
  47. # > $ dockerinspect --format '{{json .Config.Entrypoint}}' homeassistant/home-assistant:0.107.0
  48. # > ["/init"]
  49. # > $ dockerinspect --format '{{json .Config.Cmd}}' homeassistant/home-assistant:0.107.0
  50. # > null
  51. # see https://github.com/home-assistant/docker-base/pull/62
  52. # > For now, `s6-overlay` doesn't support running it with a user different than `root`, so consequently Dockerfile `USER` directive is not supported (except `USER root` of course ;P).
  53. # src: https://github.com/just-containers/s6-overlay/blame/v1.22.1.0/README.md#L420
  54. # workaround: disable useless (but annoying) s6-overlay
  55. ENTRYPOINT ["tini", "--"]
  56. # default in home-assistant<0.107.0
  57. CMD ["python3", "-m", "homeassistant", "--config", "/config"]
  58. # https://github.com/opencontainers/image-spec/blob/v1.0.1/annotations.md
  59. ARG HOME_ASSISTANT_VERSION
  60. ARG REVISION=
  61. LABEL org.opencontainers.image.title="homeassistant/home-assistant:$HOME_ASSISTANT_VERSION running as unprivileged user" \
  62. org.opencontainers.image.source="https://github.com/fphammerle/docker-home-assistant" \
  63. org.opencontainers.image.revision="$REVISION"