FROM python:3.9-slim-buster

ARG HA_VER=2021.7.4

ARG DEBIAN_FRONTEND=noninteractive

RUN \
  apt-get update \
  && \
  apt-get upgrade -y \
  && \
  apt-get install -y \
  python3 \
  python3-dev \
  python3-venv \
  python3-pip \
  libffi-dev \
  libssl-dev \
  libjpeg-dev \
  zlib1g-dev \
  autoconf \
  build-essential \
  libopenjp2-7 \
  libtiff5 \
  tzdata \
  python3-gst-1.0 \
  gir1.2-gstreamer-1.0 \
  gir1.2-gst-plugins-base-1.0 \
  gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-ugly \
  gstreamer1.0-tools \
  && \
  apt-get -y --purge autoremove \
  && \
  apt-get clean \
  && \
  rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/*

RUN \
  python3 -m pip install wheel \
  && \
  pip3 install homeassistant==${HA_VER}

EXPOSE 8123
VOLUME /config

CMD [ "/usr/bin/hass", "-c", "/config" ]
