Add runtime image targets without build toolchain - #89
Open
gmarti wants to merge 1 commit into
Open
Conversation
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.
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
diveand poking around the image layers, it turns outbuild-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 toolchainbase— runtime + build-essential (unchanged, used duringpip installfor native extensions)ha-addon-runtime/ha-addon— same split for the HA add-on variantThe
baseandha-addontargets are fully backwards-compatible. The newruntimeandha-addon-runtimetargets are meant to be used as the final stage in a multi-stage ESPHome build (companion PR: esphome/esphome#XXXX).Testing
Note
I was assisted by Claude (Anthropic) in investigating the image size and drafting this change. Happy to iterate on feedback!