Browse Source

unset suid/guid flags; remove env vars; no longer install runtime deps; use /config volume

Fabian Peter Hammerle 5 years ago
parent
commit
477bc4e333
3 changed files with 12 additions and 42 deletions
  1. 8 10
      Dockerfile
  2. 4 0
      README.md
  3. 0 32
      python-requirements.txt

+ 8 - 10
Dockerfile

@@ -1,16 +1,14 @@
 FROM python:3.7
 
-ENV HASS_USER hass
-ENV HASS_HOME "/home/${HASS_USER}"
+RUN find /usr/bin -type f -perm /u+s -exec echo chmod --changes u-s {} \;
+RUN find /usr/bin -type f -perm /g+s -exec echo chmod --changes g-s {} \;
 
-RUN useradd --home-dir "$HASS_HOME" --create-home "$HASS_USER" \
-    && chown hass:hass "$HASS_HOME"
-USER "$HASS_USER"
+VOLUME /config
 
-ENV PATH "${HASS_HOME}/.local/bin:${PATH}"
+RUN useradd --create-home hass && chown hass ~hass
+USER hass
+ENV PATH "/home/hass/.local/bin:${PATH}"
 
-COPY ./python-requirements.txt .
-RUN pip install --user --no-cache-dir --requirement python-requirements.txt
+RUN pip install --user --no-cache-dir homeassistant
 
-EXPOSE 8123
-CMD ["python", "-m", "homeassistant"]
+CMD ["python", "-m", "homeassistant", "--config", "/config"]

+ 4 - 0
README.md

@@ -2,9 +2,13 @@ https://www.home-assistant.io/docs/installation/docker/
 
 https://github.com/home-assistant/home-assistant/blob/dev/virtualization/Docker/setup_docker_prereqs
 
+https://github.com/home-assistant/home-assistant/blob/dev/requirements_all.txt
+
 ```sh
 sudo docker build --tag=home-assistant .
+sudo docker volume create home-assistant-config
 sudo docker run --rm --publish=8123:8123 \
+    --mount "source=home-assistant-config,target=/config" \
     --security-opt=no-new-privileges --cap-drop=all \
     home-assistant
 ```

+ 0 - 32
python-requirements.txt

@@ -1,32 +0,0 @@
-# compare https://github.com/home-assistant/home-assistant/blob/dev/requirements_all.txt
-
-homeassistant
-
-aiohttp==3.4.0
-voluptuous==0.11.5
-
-# homeassistant.components.emulated_hue
-# homeassistant.components.http
-aiohttp_cors==0.7.0
-
-# homeassistant.components.frontend
-home-assistant-frontend==20180903.0
-
-# homeassistant.components.discovery
-netdisco==2.0.0
-
-# homeassistant.components.recorder
-# homeassistant.scripts.db_migrator
-# homeassistant.components.sensor.sql
-sqlalchemy==1.2.11
-
-# homeassistant.components.config.config_entries
-voluptuous-serialize==2.0.0
-
-# homeassistant.components.media_player.bluesound
-# homeassistant.components.sensor.startca
-# homeassistant.components.sensor.swiss_hydrological_data
-# homeassistant.components.sensor.ted5000
-# homeassistant.components.sensor.yr
-# homeassistant.components.sensor.zestimate
-xmltodict==0.11.0