2021-09-20 09:07:38 +02:00
|
|
|
# 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
|
|
|
|
|
2022-02-16 22:25:04 +01:00
|
|
|
# https://github.com/hassio-addons/addon-debian-base/releases
|
2022-03-09 13:48:02 +01:00
|
|
|
FROM ghcr.io/hassio-addons/debian-base/amd64:5.3.0 AS base-hassio-amd64
|
|
|
|
FROM ghcr.io/hassio-addons/debian-base/aarch64:5.3.0 AS base-hassio-arm64
|
|
|
|
FROM ghcr.io/hassio-addons/debian-base/armv7:5.3.0 AS base-hassio-armv7
|
2022-02-16 22:25:04 +01:00
|
|
|
# https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye
|
2022-04-04 19:21:43 +02:00
|
|
|
FROM debian:bullseye-20220328-slim AS base-docker-amd64
|
|
|
|
FROM debian:bullseye-20220328-slim AS base-docker-arm64
|
|
|
|
FROM debian:bullseye-20220328-slim AS base-docker-armv7
|
2021-09-20 09:07:38 +02:00
|
|
|
|
|
|
|
# Use TARGETARCH/TARGETVARIANT defined by docker
|
|
|
|
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
|
|
|
FROM base-${BASEIMGTYPE}-${TARGETARCH}${TARGETVARIANT} AS base
|
|
|
|
|
|
|
|
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 \
|
2021-09-20 09:07:38 +02:00
|
|
|
python3-setuptools=52.0.0-4 \
|
2022-01-29 13:04:15 +01:00
|
|
|
python3-pil=8.1.2+dfsg-0.3+deb11u1 \
|
2021-09-20 09:07:38 +02:00
|
|
|
python3-cryptography=3.3.2-1 \
|
|
|
|
iputils-ping=3:20210202-1 \
|
|
|
|
git=1:2.30.2-1 \
|
2021-12-22 03:27:34 +01:00
|
|
|
curl=7.74.0-1.3+deb11u1 \
|
2022-04-26 00:09:49 +02:00
|
|
|
openssh-client=1:8.4p1-5 \
|
2021-09-20 09:07:38 +02:00
|
|
|
&& 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
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
# Ubuntu python3-pip is missing wheel
|
|
|
|
pip3 install --no-cache-dir \
|
2022-01-08 14:15:05 +01:00
|
|
|
wheel==0.37.1 \
|
2022-06-21 01:53:51 +02:00
|
|
|
platformio==6.0.2 \
|
2021-09-20 09:07:38 +02:00
|
|
|
# Change some platformio settings
|
|
|
|
&& platformio settings set enable_telemetry No \
|
|
|
|
&& platformio settings set check_platformio_interval 1000000 \
|
|
|
|
&& mkdir -p /piolibs
|
2019-02-13 16:54:02 +01:00
|
|
|
|
2021-09-20 10:31:48 +02:00
|
|
|
|
2020-07-15 15:03:15 +02:00
|
|
|
# First install requirements to leverage caching when requirements don't change
|
2021-06-08 22:03:04 +02:00
|
|
|
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
2021-03-20 18:43:31 +01:00
|
|
|
RUN \
|
2021-06-08 22:03:04 +02:00
|
|
|
pip3 install --no-cache-dir -r /requirements.txt -r /requirements_optional.txt \
|
2021-03-20 18:43:31 +01:00
|
|
|
&& /platformio_install_deps.py /platformio.ini
|
2020-07-15 15:03:15 +02:00
|
|
|
|
2022-02-16 22:25:04 +01:00
|
|
|
|
|
|
|
# ======================= docker-type image =======================
|
|
|
|
FROM base AS docker
|
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
# Copy esphome and install
|
|
|
|
COPY . /esphome
|
2022-01-04 10:16:02 +01:00
|
|
|
RUN pip3 install --no-cache-dir --no-use-pep517 -e /esphome
|
2019-02-13 16:54:02 +01:00
|
|
|
|
2020-07-15 15:03:15 +02:00
|
|
|
# Settings for dashboard
|
|
|
|
ENV USERNAME="" PASSWORD=""
|
2019-10-13 13:52:02 +02:00
|
|
|
|
2020-12-30 10:58:09 +01:00
|
|
|
# Expose the dashboard to Docker
|
|
|
|
EXPOSE 6052
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ======================= 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 \
|
2022-07-25 06:04:21 +02:00
|
|
|
nginx-light=1.18.0-6.1+deb11u2 \
|
2021-09-20 09:07:38 +02:00
|
|
|
&& rm -rf \
|
|
|
|
/tmp/* \
|
|
|
|
/var/{cache,log}/* \
|
|
|
|
/var/lib/apt/lists/*
|
|
|
|
|
|
|
|
ARG BUILD_VERSION=dev
|
|
|
|
|
|
|
|
# Copy root filesystem
|
2022-02-09 11:46:20 +01:00
|
|
|
COPY docker/ha-addon-rootfs/ /
|
2021-09-20 09:07:38 +02:00
|
|
|
|
|
|
|
# Copy esphome and install
|
|
|
|
COPY . /esphome
|
2022-01-04 10:16:02 +01:00
|
|
|
RUN pip3 install --no-cache-dir --no-use-pep517 -e /esphome
|
2021-09-20 09:07:38 +02:00
|
|
|
|
|
|
|
# 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-11=1:11.0.1-2 \
|
|
|
|
clang-tidy-11=1:11.0.1-2 \
|
|
|
|
patch=2.7.6-7 \
|
|
|
|
software-properties-common=0.96.20.2-2.1 \
|
2022-07-25 06:04:21 +02:00
|
|
|
nano=5.4-2+deb11u1 \
|
2021-09-20 09:07:38 +02:00
|
|
|
build-essential=12.9 \
|
|
|
|
python3-dev=3.9.2-3 \
|
|
|
|
&& rm -rf \
|
|
|
|
/tmp/* \
|
|
|
|
/var/{cache,log}/* \
|
|
|
|
/var/lib/apt/lists/*
|
|
|
|
|
2022-02-16 22:25:04 +01:00
|
|
|
COPY requirements_test.txt /
|
|
|
|
RUN pip3 install --no-cache-dir -r /requirements_test.txt
|
2021-09-20 10:31:48 +02:00
|
|
|
|
2021-09-20 09:07:38 +02:00
|
|
|
VOLUME ["/esphome"]
|
|
|
|
WORKDIR /esphome
|