esphome/docker/Dockerfile

166 lines
4.9 KiB
Docker
Raw Normal View History

# Build these with the build.py script
# Example:
# python3 docker/build.py --tag dev --arch amd64 --build-type docker build
# One of "docker", "hassio"
ARG BASEIMGTYPE=docker
# https://github.com/hassio-addons/addon-debian-base/releases
FROM ghcr.io/hassio-addons/debian-base:6.2.3 AS base-hassio
# https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye
FROM debian:bullseye-20230208-slim AS base-docker
FROM base-${BASEIMGTYPE} AS base
ARG TARGETARCH
ARG TARGETVARIANT
RUN \
apt-get update \
# Use pinned versions so that we get updates with build caching
&& apt-get install -y --no-install-recommends \
python3=3.9.2-3 \
2022-04-04 19:21:43 +02:00
python3-pip=20.3.4-4+deb11u1 \
python3-setuptools=52.0.0-4 \
python3-cryptography=3.3.2-1 \
Initial attempt at supporting ESP-IDF 5.0.0 (#4364) * requirements: add pyparsing >= 3.0 ESP-IDF >= 5.0 requires pyparsing's rest_of_file, which was introduced in version 3.0. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * esp32: fix build with ESP-IDF >= 5 We need to include esp_timer.h to be able to use esp_timer_get_time(). This header existed in ESP-IDF < 5 so we don't need if guards. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * ota: fix build with ESP-IDF >= 5 As of version 5, esp_task_wdt_init() takes a struct as argument. We also need to include spi_flash_mmap.h. [split unrelated change into separate commits, maintain ESP-IDF < 5 compat, use esp_task_wdt_reconfigure, add commit message] Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * core: fix build with ESP-IDF >= 5 These header files already existed in ESP-IDF < 5 so skip if guards. [add commit message] Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * wifi: fix build with ESP-IDF >= 5 ESP-IDF 4.1 introduced the esp-netif API as successor to the tcp_adapter API. The tcp_adapter API was removed in ESP-IDF 5.0.0. Part of the wifi component was already migrated to the new API. Migrate the leftover uses of the old API to the new API to fix build on ESP-IDF >= 5. The version of ESP-IDF currently in use (4.4.4) supports the new API, so we don't need any if guards to maintain backwards compatibility. Also replace xQueueHandle, which is a pre FreeRTOS v8.0.0 data type, with QueueHandle_t, so we don't need to enable backward compatibility (CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY). This reverts part of commit d42f35de5d54 to wifi_component_esp_idf.cpp, as the esp-netif API handles that internally. [replace pre FreeRTOS v8.0.0 data type, add commit message] Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * mdns: fix build with ESP-IDF >= 5 In ESP-IDF 5.0.0, the mdns component was removed and moved to another repository. Since the mdns component in esphome is always built, we need to add the mdns component from the esp-protocols repository. This component depends on ESP-IDF >= 5.0, so we need to add a version guard. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> * docker: install python3-venv As of version 6.0.1, platform-espressif32 requires python3-venv. Switching between esp-idf 4.4.4 and 5.0 causes problems with esp-idf python dependencies installed by PlatformIO. They've solved this by using venv. Install python3-venv so that platform-espressif32 6.0.1 and later can be used, and we don't need to wipe the dependencies manually when switching esp-idf versions. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> --------- Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> Co-authored-by: Stijn Tintel <stijn@linux-ipv6.be>
2023-04-20 05:54:06 +02:00
python3-venv=3.9.2-3 \
iputils-ping=3:20210202-1 \
2023-04-30 22:51:46 +02:00
git=1:2.30.2-1+deb11u2 \
curl=7.74.0-1.3+deb11u10 \
2023-10-09 00:13:12 +02:00
openssh-client=1:8.4p1-5+deb11u2 \
python3-cffi=1.14.5-1 \
2023-09-14 01:13:55 +02:00
libcairo2=1.16.0-5 \
patch=2.7.6-7; \
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
apt-get install -y --no-install-recommends \
build-essential=12.9 \
python3-dev=3.9.2-3 \
zlib1g-dev=1:1.2.11.dfsg-2+deb11u2 \
libjpeg-dev=1:2.0.6-4 \
libfreetype-dev=2.10.4+dfsg-1+deb11u1; \
fi; \
rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
ENV \
# Fix click python3 lang warning https://click.palletsprojects.com/en/7.x/python3/
LANG=C.UTF-8 LC_ALL=C.UTF-8 \
# Store globally installed pio libs in /piolibs
PLATFORMIO_GLOBALLIB_DIR=/piolibs
# Support legacy binaries on Debian multiarch system. There is no "correct" way
# to do this, other than using properly built toolchains...
# See: https://unix.stackexchange.com/questions/553743/correct-way-to-add-lib-ld-linux-so-3-in-debian
RUN \
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \
ln -s /lib/arm-linux-gnueabihf/ld-linux.so.3 /lib/ld-linux.so.3; \
fi
RUN \
# Ubuntu python3-pip is missing wheel
pip3 install --no-cache-dir \
2022-01-08 14:15:05 +01:00
wheel==0.37.1 \
platformio==6.1.11 \
# Change some platformio settings
&& platformio settings set enable_telemetry No \
&& platformio settings set check_platformio_interval 1000000 \
&& mkdir -p /piolibs
# First install requirements to leverage caching when requirements don't change
COPY requirements.txt requirements_optional.txt script/platformio_install_deps.py platformio.ini /
RUN \
2021-06-08 22:03:04 +02:00
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
&& /platformio_install_deps.py /platformio.ini --libraries
# ======================= docker-type image =======================
FROM base AS docker
# Copy esphome and install
COPY . /esphome
RUN pip3 install --no-cache-dir --no-use-pep517 -e /esphome
# Settings for dashboard
ENV USERNAME="" PASSWORD=""
2020-12-30 10:58:09 +01:00
# Expose the dashboard to Docker
EXPOSE 6052
COPY docker/docker_entrypoint.sh /entrypoint.sh
2021-01-27 07:16:59 +01:00
# The directory the user should mount their configuration files to
VOLUME /config
WORKDIR /config
# Set entrypoint to esphome (via a script) so that the user doesn't have to type 'esphome'
# in every docker command twice
ENTRYPOINT ["/entrypoint.sh"]
# When no arguments given, start the dashboard in the workdir
CMD ["dashboard", "/config"]
# ======================= hassio-type image =======================
FROM base AS hassio
RUN \
apt-get update \
# Use pinned versions so that we get updates with build caching
&& apt-get install -y --no-install-recommends \
nginx-light=1.18.0-6.1+deb11u3 \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
ARG BUILD_VERSION=dev
# Copy root filesystem
COPY docker/ha-addon-rootfs/ /
# Copy esphome and install
COPY . /esphome
RUN pip3 install --no-cache-dir --no-use-pep517 -e /esphome
# Labels
LABEL \
io.hass.name="ESPHome" \
io.hass.description="Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files" \
io.hass.type="addon" \
io.hass.version="${BUILD_VERSION}"
# io.hass.arch is inherited from addon-debian-base
# ======================= lint-type image =======================
FROM base AS lint
ENV \
PLATFORMIO_CORE_DIR=/esphome/.temp/platformio
RUN \
apt-get update \
# Use pinned versions so that we get updates with build caching
&& apt-get install -y --no-install-recommends \
clang-format-13=1:13.0.1-6~deb11u1 \
clang-tidy-11=1:11.0.1-2 \
patch=2.7.6-7 \
software-properties-common=0.96.20.2-2.1 \
nano=5.4-2+deb11u2 \
build-essential=12.9 \
python3-dev=3.9.2-3 \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
COPY requirements_test.txt /
RUN pip3 install --no-cache-dir -r /requirements_test.txt
VOLUME ["/esphome"]
WORKDIR /esphome