Skip to content

Add runtime image targets without build toolchain - #89

Open
gmarti wants to merge 1 commit into
esphome:mainfrom
gmarti:slim-runtime-image
Open

Add runtime image targets without build toolchain#89
gmarti wants to merge 1 commit into
esphome:mainfrom
gmarti:slim-runtime-image

Conversation

@gmarti

@gmarti gmarti commented Jul 25, 2026

Copy link
Copy Markdown

I wanted to see if the ESPHome Docker image could be made lighter on my Home Assistant setup — it's currently ~940 MB which felt like a lot for a microcontroller configuration tool.

After investigating with dive and poking around the image layers, it turns out build-essential + GCC + sanitizer libraries account for ~250 MB but aren't needed at runtime — PlatformIO downloads its own cross-compilers (xtensa, arm-none-eabi) when it compiles firmware.

This PR splits the Dockerfile into:

  • runtime — everything needed at runtime (git, curl, libusb, libcairo…) but no compiler toolchain
  • base — runtime + build-essential (unchanged, used during pip install for native extensions)
  • ha-addon-runtime / ha-addon — same split for the HA add-on variant

The base and ha-addon targets are fully backwards-compatible. The new runtime and ha-addon-runtime targets are meant to be used as the final stage in a multi-stage ESPHome build (companion PR: esphome/esphome#XXXX).

Testing

  • Built locally on amd64
  • ESP32-S3 (ESP-IDF) firmware compiles successfully in the slim image
  • Dashboard starts and serves correctly

Note

I was assisted by Claude (Anthropic) in investigating the image size and drafting this change. Happy to iterate on feedback!

Add a 'runtime' target without build-essential/ccache (~250 MB smaller)
for use as the final image in multi-stage ESPHome builds.

The 'base' target retains build-essential and is used during pip install
to compile native Python C extensions.

Similarly, 'ha-addon-runtime' provides the HA add-on base without
build tools, while 'ha-addon' keeps them for the build stage.

PlatformIO does not need the host GCC — it downloads its own
cross-compilers (xtensa, arm-none-eabi) at compile time.

Tested locally: ESP32 firmware compiles successfully in the slim image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant