From 11daabc9c25a7f4dda4bf3c5a111ab31e15774cf Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 22 Sep 2021 10:32:39 +0200 Subject: [PATCH] Fix docker pio settings not applied (#2370) --- docker/docker_entrypoint.sh | 16 +++++++++++----- docker/hassio-rootfs/etc/cont-init.d/30-dirs.sh | 4 ++-- docker/hassio-rootfs/etc/services.d/esphome/run | 8 +++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docker/docker_entrypoint.sh b/docker/docker_entrypoint.sh index b3905d1fed..75d5e0b7b5 100755 --- a/docker/docker_entrypoint.sh +++ b/docker/docker_entrypoint.sh @@ -4,15 +4,21 @@ # otherwise use path in /config (so that PIO packages aren't downloaded on each compile) if [[ -d /cache ]]; then - export PLATFORMIO_CORE_DIR=/cache/platformio + pio_cache_base=/cache/platformio else - export PLATFORMIO_CORE_DIR=/config/.esphome/platformio + pio_cache_base=/config/.esphome/platformio fi -if [[ ! -d "${PLATFORMIO_CORE_DIR}" ]]; then - echo "Creating cache directory ${PLATFORMIO_CORE_DIR}" +if [[ ! -d "${pio_cache_base}" ]]; then + echo "Creating cache directory ${pio_cache_base}" echo "You can change this behavior by mounting a directory to the container's /cache directory." - mkdir -p "${PLATFORMIO_CORE_DIR}" + mkdir -p "${pio_cache_base}" fi +# we can't set core_dir, because the settings file is stored in `core_dir/appstate.json` +# setting `core_dir` would therefore prevent pio from accessing +export PLATFORMIO_PLATFORMS_DIR="${pio_cache_base}/platforms" +export PLATFORMIO_PACKAGES_DIR="${pio_cache_base}/packages" +export PLATFORMIO_CACHE_DIR="${pio_cache_base}/cache" + exec esphome "$@" diff --git a/docker/hassio-rootfs/etc/cont-init.d/30-dirs.sh b/docker/hassio-rootfs/etc/cont-init.d/30-dirs.sh index 301fe4db63..1073a2fa45 100644 --- a/docker/hassio-rootfs/etc/cont-init.d/30-dirs.sh +++ b/docker/hassio-rootfs/etc/cont-init.d/30-dirs.sh @@ -4,6 +4,6 @@ # This files creates all directories used by esphome # ============================================================================== -PLATFORMIO_CORE_DIR=/data/cache/platformio +pio_cache_base=/data/cache/platformio -mkdir -p "${PLATFORMIO_CORE_DIR}" +mkdir -p "${pio_cache_base}" diff --git a/docker/hassio-rootfs/etc/services.d/esphome/run b/docker/hassio-rootfs/etc/services.d/esphome/run index 6218b200bd..a0f20d63d6 100755 --- a/docker/hassio-rootfs/etc/services.d/esphome/run +++ b/docker/hassio-rootfs/etc/services.d/esphome/run @@ -22,7 +22,13 @@ if bashio::config.has_value 'relative_url'; then export ESPHOME_DASHBOARD_RELATIVE_URL=$(bashio::config 'relative_url') fi -export PLATFORMIO_CORE_DIR=/data/cache/platformio +pio_cache_base=/data/cache/platformio +# we can't set core_dir, because the settings file is stored in `core_dir/appstate.json` +# setting `core_dir` would therefore prevent pio from accessing +export PLATFORMIO_PLATFORMS_DIR="${pio_cache_base}/platforms" +export PLATFORMIO_PACKAGES_DIR="${pio_cache_base}/packages" +export PLATFORMIO_CACHE_DIR="${pio_cache_base}/cache" + export PLATFORMIO_GLOBALLIB_DIR=/piolibs bashio::log.info "Starting ESPHome dashboard..."