Skip to content

Commit 159a8d3

Browse files
edenhausCopilot
andauthored
Optimize build_base build job (home-assistant#157231)
Co-authored-by: Copilot <[email protected]>
1 parent 8f1abb6 commit 159a8d3

File tree

5 files changed

+82
-39
lines changed

5 files changed

+82
-39
lines changed

.github/workflows/builder.yml

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ env:
1414
PIP_TIMEOUT: 60
1515
UV_HTTP_TIMEOUT: 60
1616
UV_SYSTEM_PYTHON: "true"
17+
BASE_IMAGE_VERSION: "2025.11.0"
1718

1819
jobs:
1920
init:
2021
name: Initialize build
2122
if: github.repository_owner == 'home-assistant'
2223
runs-on: ubuntu-latest
2324
outputs:
24-
architectures: ${{ steps.info.outputs.architectures }}
2525
version: ${{ steps.version.outputs.version }}
2626
channel: ${{ steps.version.outputs.channel }}
2727
publish: ${{ steps.version.outputs.publish }}
@@ -77,15 +77,20 @@ jobs:
7777
name: Build ${{ matrix.arch }} base core image
7878
if: github.repository_owner == 'home-assistant'
7979
needs: init
80-
runs-on: ubuntu-latest
80+
runs-on: ${{ matrix.os }}
8181
permissions:
8282
contents: read
8383
packages: write
8484
id-token: write
8585
strategy:
8686
fail-fast: false
8787
matrix:
88-
arch: ${{ fromJson(needs.init.outputs.architectures) }}
88+
arch: ["amd64", "aarch64"]
89+
include:
90+
- arch: amd64
91+
os: ubuntu-latest
92+
- arch: aarch64
93+
os: ubuntu-24.04-arm
8994
steps:
9095
- name: Checkout the repository
9196
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -182,16 +187,59 @@ jobs:
182187
username: ${{ github.repository_owner }}
183188
password: ${{ secrets.GITHUB_TOKEN }}
184189

185-
# home-assistant/builder doesn't support sha pinning
190+
- name: Install Cosign
191+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
192+
with:
193+
cosign-release: "v2.5.3"
194+
195+
- name: Set up Docker Buildx
196+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
197+
198+
- name: Build variables
199+
id: vars
200+
shell: bash
201+
run: |
202+
echo "base_image=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant-base:${{ env.BASE_IMAGE_VERSION }}" >> "$GITHUB_OUTPUT"
203+
echo "cache_image=ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:latest" >> "$GITHUB_OUTPUT"
204+
echo "created=$(date --rfc-3339=seconds --utc)" >> "$GITHUB_OUTPUT"
205+
206+
- name: Verify base image signature
207+
run: |
208+
cosign verify \
209+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
210+
--certificate-identity-regexp "https://github.com/home-assistant/docker/.*" \
211+
"${{ steps.vars.outputs.base_image }}"
212+
213+
- name: Verify cache image signature
214+
id: cache
215+
continue-on-error: true
216+
run: |
217+
cosign verify \
218+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
219+
--certificate-identity-regexp "https://github.com/home-assistant/core/.*" \
220+
"${{ steps.vars.outputs.cache_image }}"
221+
186222
- name: Build base image
187-
uses: home-assistant/[email protected]
223+
id: build
224+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
188225
with:
189-
args: |
190-
$BUILD_ARGS \
191-
--${{ matrix.arch }} \
192-
--cosign \
193-
--target /data \
194-
--generic ${{ needs.init.outputs.version }}
226+
context: .
227+
file: ./Dockerfile
228+
platforms: ${{ steps.vars.outputs.platform }}
229+
push: true
230+
cache-from: ${{ steps.cache.outcome == 'success' && steps.vars.outputs.cache_image || '' }}
231+
build-args: |
232+
BUILD_FROM=${{ steps.vars.outputs.base_image }}
233+
tags: ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:${{ needs.init.outputs.version }}
234+
labels: |
235+
io.hass.arch=${{ matrix.arch }}
236+
io.hass.version=${{ needs.init.outputs.version }}
237+
org.opencontainers.image.created=${{ steps.vars.outputs.created }}
238+
org.opencontainers.image.version=${{ needs.init.outputs.version }}
239+
240+
- name: Sign image
241+
run: |
242+
cosign sign --yes "ghcr.io/home-assistant/${{ matrix.arch }}-homeassistant:${{ needs.init.outputs.version }}@${{ steps.build.outputs.digest }}"
195243
196244
build_machine:
197245
name: Build ${{ matrix.machine }} machine core image

.github/workflows/wheels.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
name: Initialize wheels builder
2929
if: github.repository_owner == 'home-assistant'
3030
runs-on: ubuntu-latest
31-
outputs:
32-
architectures: ${{ steps.info.outputs.architectures }}
3331
steps:
3432
- &checkout
3533
name: Checkout the repository
@@ -50,10 +48,6 @@ jobs:
5048
pip install "$(grep '^uv' < requirements.txt)"
5149
uv pip install -r requirements.txt
5250
53-
- name: Get information
54-
id: info
55-
uses: home-assistant/actions/helpers/info@master
56-
5751
- name: Create requirements_diff file
5852
run: |
5953
if [[ ${{ github.event_name }} =~ (schedule|workflow_dispatch) ]]; then
@@ -114,9 +108,10 @@ jobs:
114108
fail-fast: false
115109
matrix: &matrix-build
116110
abi: ["cp313", "cp314"]
117-
arch: ${{ fromJson(needs.init.outputs.architectures) }}
111+
arch: ["amd64", "aarch64"]
118112
include:
119-
- os: ubuntu-latest
113+
- arch: amd64
114+
os: ubuntu-latest
120115
- arch: aarch64
121116
os: ubuntu-24.04-arm
122117
steps:

Dockerfile

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

script/hassfest/docker.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121
ARG BUILD_FROM
2222
FROM ${{BUILD_FROM}}
2323
24+
LABEL \
25+
io.hass.type="core" \
26+
org.opencontainers.image.authors="The Home Assistant Authors" \
27+
org.opencontainers.image.description="Open-source home automation platform running on Python 3" \
28+
org.opencontainers.image.documentation="https://www.home-assistant.io/docs/" \
29+
org.opencontainers.image.licenses="Apache-2.0" \
30+
org.opencontainers.image.source="https://github.com/home-assistant/core" \
31+
org.opencontainers.image.title="Home Assistant" \
32+
org.opencontainers.image.url="https://www.home-assistant.io/"
33+
2434
# Synchronize with homeassistant/core.py:async_stop
2535
ENV \
2636
S6_SERVICES_GRACETIME={timeout} \
2737
UV_SYSTEM_PYTHON=true \
2838
UV_NO_CACHE=true
2939
30-
ARG QEMU_CPU
31-
3240
# Home Assistant S6-Overlay
3341
COPY rootfs /
3442

0 commit comments

Comments
 (0)