2025-04-28 11:14:50 +12:00
ARG BUILD_VERSION = dev
ARG BUILD_OS = alpine
ARG BUILD_BASE_VERSION = 2025 .04.0
ARG BUILD_TYPE = docker
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
FROM ghcr.io/esphome/docker-base:${BUILD_OS}-${BUILD_BASE_VERSION } AS base-source-docker
FROM ghcr.io/esphome/docker-base:${BUILD_OS}-ha-addon-${BUILD_BASE_VERSION } AS base-source-ha-addon
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
ARG BUILD_TYPE
FROM base-source-${BUILD_TYPE } AS base
2023-11-09 02:04:39 -06:00
2026-02-12 16:12:17 -05:00
RUN git config --system --add safe.directory "*" \
&& git config --system advice.detachedHead false
2021-09-20 09:07:38 +02:00
2025-12-31 11:05:58 -10:00
# Install build tools for Python packages that require compilation
# (e.g., ruamel.yaml.clibz used by ESP-IDF's idf-component-manager)
RUN if command -v apk > /dev/null; then \
apk add --no-cache build-base; \
else \
apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*; \
fi
2025-05-19 18:22:24 +12:00
ENV PIP_DISABLE_PIP_VERSION_CHECK = 1
2026-02-10 19:44:12 -05:00
RUN pip install --no-cache-dir -U pip uv == 0.10.1
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
COPY requirements.txt /
2023-10-17 20:33:19 -10:00
2021-09-20 09:07:38 +02:00
RUN \
2025-04-28 11:14:50 +12:00
uv pip install --no-cache-dir \
-r /requirements.txt
2023-10-17 20:33:19 -10:00
2022-12-15 21:27:59 +01:00
RUN \
2025-04-28 11:14:50 +12:00
platformio settings set enable_telemetry No \
2021-09-20 09:07:38 +02:00
&& platformio settings set check_platformio_interval 1000000 \
&& mkdir -p /piolibs
2019-02-13 16:54:02 +01:00
2024-09-10 10:35:39 +12:00
COPY script/platformio_install_deps.py platformio.ini /
RUN /platformio_install_deps.py /platformio.ini --libraries
2020-07-15 15:03:15 +02:00
2025-04-28 11:14:50 +12:00
ARG BUILD_VERSION
LABEL \
org.opencontainers.image.authors= "The ESPHome Authors" \
org.opencontainers.image.title= "ESPHome" \
org.opencontainers.image.description= "ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems" \
org.opencontainers.image.url= "https://esphome.io/" \
org.opencontainers.image.documentation= "https://esphome.io/" \
org.opencontainers.image.source= "https://github.com/esphome/esphome" \
org.opencontainers.image.licenses= "ESPHome" \
org.opencontainers.image.version= ${ BUILD_VERSION }
2024-06-03 18:34:47 -07:00
2022-02-16 22:25:04 +01:00
# ======================= docker-type image =======================
2025-04-28 11:14:50 +12:00
FROM base AS base-docker
2019-10-13 14:52:02 +03:00
2020-12-30 10:58:09 +01:00
# Expose the dashboard to Docker
EXPOSE 6052
2023-11-02 19:19:43 +01:00
# Run healthcheck (heartbeat)
HEALTHCHECK --interval= 30s --timeout= 30s \
2025-04-28 11:14:50 +12:00
CMD curl --fail http://localhost:6052/version -A "HealthCheck" || exit 1
2023-11-02 19:19:43 +01:00
2021-09-20 09:07:38 +02:00
COPY docker/docker_entrypoint.sh /entrypoint.sh
2021-01-27 07:16:59 +01:00
2020-07-15 15:03:15 +02:00
# The directory the user should mount their configuration files to
2021-09-20 09:07:38 +02:00
VOLUME /config
2019-02-13 16:54:02 +01:00
WORKDIR /config
2021-09-20 09:07:38 +02:00
# Set entrypoint to esphome (via a script) so that the user doesn't have to type 'esphome'
2020-07-15 15:03:15 +02:00
# in every docker command twice
2021-09-20 09:07:38 +02:00
ENTRYPOINT [ "/entrypoint.sh" ]
2020-07-15 15:03:15 +02:00
# When no arguments given, start the dashboard in the workdir
2021-06-08 01:14:12 +02:00
CMD [ "dashboard" , "/config" ]
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
# ======================= ha-addon-type image =======================
FROM base AS base-ha-addon
2021-09-20 09:07:38 +02:00
# Copy root filesystem
2022-02-09 23:46:20 +13:00
COPY docker/ha-addon-rootfs/ /
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
ARG BUILD_VERSION
2021-09-20 09:07:38 +02:00
LABEL \
io.hass.name= "ESPHome" \
2024-12-06 15:24:20 +13:00
io.hass.description= "ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems" \
2021-09-20 09:07:38 +02:00
io.hass.type= "addon" \
2024-12-06 14:11:11 +13:00
io.hass.version= " ${ BUILD_VERSION } "
2021-09-20 09:07:38 +02:00
# io.hass.arch is inherited from addon-debian-base
2025-04-28 11:14:50 +12:00
ARG BUILD_TYPE
FROM base-${BUILD_TYPE } AS final
2021-09-20 09:07:38 +02:00
2025-04-28 11:14:50 +12:00
# Copy esphome and install
COPY . /esphome
RUN uv pip install --no-cache-dir -e /esphome