Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ jobs:
fi
echo version="$version" >> $GITHUB_OUTPUT

- name: Build runtime image
id: build-runtime
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
continue-on-error: ${{ github.event_name == 'pull_request' }}
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: ${{ matrix.base }}
file: ./${{ matrix.base }}/Dockerfile
platforms: linux/amd64,linux/arm64
target: runtime
cache-from: type=registry,ref=${{ steps.image.outputs.image }}:cache-${{ matrix.base }}
cache-to: ${{ github.event_name == 'release' && format('type=registry,ref={0}:cache-{1},mode=max', steps.image.outputs.image, matrix.base) || '' }}
push: true
tags: |
${{ steps.image.outputs.image }}:${{ matrix.base }}-runtime-${{ steps.get_tag.outputs.version }}

- name: Build base image
id: build-base
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
Expand All @@ -85,6 +103,24 @@ jobs:
tags: |
${{ steps.image.outputs.image }}:${{ matrix.base }}-${{ steps.get_tag.outputs.version }}

- name: Build ha-addon-runtime image
id: build-ha-addon-runtime
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
continue-on-error: ${{ github.event_name == 'pull_request' }}
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: ${{ matrix.base }}
file: ./${{ matrix.base }}/Dockerfile
platforms: linux/amd64,linux/arm64
target: ha-addon-runtime
cache-from: type=registry,ref=${{ steps.image.outputs.image }}:cache-${{ matrix.base }}
cache-to: ${{ github.event_name == 'release' && format('type=registry,ref={0}:cache-{1},mode=max', steps.image.outputs.image, matrix.base) || '' }}
push: true
tags: |
${{ steps.image.outputs.image }}:${{ matrix.base }}-ha-addon-runtime-${{ steps.get_tag.outputs.version }}

- name: Build ha-addon image
id: build-ha-addon
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
Expand Down Expand Up @@ -114,6 +150,15 @@ jobs:
-f ./${{ matrix.base }}/Dockerfile \
./${{ matrix.base }}

- name: Build runtime image (local)
if: github.event_name == 'pull_request' && matrix.base == 'debian'
run: |
docker build \
--target runtime \
-t "ghcr.io/esphome/docker-base:${{ matrix.base }}-runtime-pr-${{ github.event.pull_request.number }}" \
-f ./${{ matrix.base }}/Dockerfile \
./${{ matrix.base }}

- name: Build ha-addon image (local)
if: github.event_name == 'pull_request' && matrix.base == 'debian'
run: |
Expand All @@ -123,6 +168,15 @@ jobs:
-f ./${{ matrix.base }}/Dockerfile \
./${{ matrix.base }}

- name: Build ha-addon-runtime image (local)
if: github.event_name == 'pull_request' && matrix.base == 'debian'
run: |
docker build \
--target ha-addon-runtime \
-t "ghcr.io/esphome/docker-base:${{ matrix.base }}-ha-addon-runtime-pr-${{ github.event.pull_request.number }}" \
-f ./${{ matrix.base }}/Dockerfile \
./${{ matrix.base }}

- name: Clone ESPHome repository
if: github.event_name == 'pull_request' && matrix.base == 'debian'
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Expand All @@ -138,7 +192,6 @@ jobs:
--target final \
--build-arg BUILD_TYPE=docker \
--build-arg BUILD_VERSION=ci \
--build-arg "BUILD_OS=${{ matrix.base }}" \
--build-arg "BUILD_BASE_VERSION=pr-${{ github.event.pull_request.number }}" \
-t esphome-test:latest \
-f ./esphome/docker/Dockerfile \
Expand Down
41 changes: 37 additions & 4 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM python:3.14-slim-trixie AS base
FROM python:3.14-slim-trixie AS runtime

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Runtime-only packages (no compiler toolchain)
RUN \
set -x \
&& apt update \
Expand All @@ -13,9 +14,7 @@ RUN \
libcairo2=1.18.4-1+b1 \
libmagic1t64=1:5.46-5 \
patch=2.8-2 \
build-essential=12.12 \
libusb-1.0-0=2:1.0.28-1 \
ccache=4.11.2-2 \
&& apt purge -y --auto-remove \
&& rm -rf \
/tmp/* \
Expand All @@ -29,7 +28,24 @@ ENV UV_SYSTEM_PYTHON=true
ENV PIP_ROOT_USER_ACTION=ignore


FROM base AS ha-addon
# Builder stage: runtime + build-essential for compiling native Python extensions
FROM runtime AS base

RUN \
set -x \
&& apt update \
&& apt install -y --no-install-recommends \
build-essential=12.12 \
ccache=4.11.2-2 \
&& apt purge -y --auto-remove \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/* \
/usr/src/*


FROM runtime AS ha-addon-runtime

RUN \
set -x \
Expand Down Expand Up @@ -90,3 +106,20 @@ RUN \

WORKDIR /root
ENTRYPOINT ["/init"]


# ha-addon with build tools (for pip install of native extensions)
FROM ha-addon-runtime AS ha-addon

RUN \
set -x \
&& apt update \
&& apt install -y --no-install-recommends \
build-essential=12.12 \
ccache=4.11.2-2 \
&& apt purge -y --auto-remove \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/* \
/usr/src/*
Loading