Skip to content

Commit 63a450f

Browse files
committed
Use minimal Debian 12 build container
1 parent 7798bda commit 63a450f

File tree

2 files changed

+105
-5
lines changed

2 files changed

+105
-5
lines changed

.github/workflows/build.yaml

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: CHIP wheels build
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release
8+
pull_request:
49

510
jobs:
611
build_prepare:
@@ -68,18 +73,87 @@ jobs:
6873
name: matter-sdk-${{ github.run_id }}
6974
path: ./connectedhomeip.tar.zst
7075

76+
build_linux_build_container:
77+
name: Build Linux container for Python wheels
78+
runs-on: ubuntu-22.04
79+
80+
permissions:
81+
contents: read
82+
packages: write # Required for pushing containers to the registry
83+
84+
outputs:
85+
container_image: ${{ steps.set_container_tag.outputs.container_image }}
86+
87+
steps:
88+
- name: Checkout Repository
89+
uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0 # Ensure we can compare changes
92+
93+
- name: Determine Container Tag and Build Necessity
94+
id: set_container_tag
95+
run: |
96+
build_needed=false
97+
tag="${{ github.ref_name }}"
98+
99+
if [ "${{ github.event_name }}" == "push" ]; then
100+
if git diff --name-only ${{ github.event.before }} HEAD | grep -E '^Dockerfile'; then
101+
echo "Dockerfile or related files changed; building container."
102+
build_needed=true
103+
fi
104+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
105+
# For pull_request, use base_ref/head_ref
106+
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then
107+
echo "Forked PR detected; using base branch container."
108+
tag="${{ github.base_ref }}"
109+
else
110+
tag="${{ github.head_ref }}"
111+
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
112+
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^Dockerfile'; then
113+
echo "Dockerfile or related files changed; building container."
114+
build_needed=true
115+
fi
116+
fi
117+
fi
118+
119+
echo "Using container with tag: ${tag}"
120+
echo "container_image=ghcr.io/${{ github.repository }}/chip-wheels-builder:${tag}" >> $GITHUB_OUTPUT
121+
echo "build_needed=${build_needed}" >> $GITHUB_ENV
122+
123+
- name: Log in to GitHub Container Registry
124+
if: ${{ env.build_needed == 'true' }}
125+
uses: docker/login-action@v2
126+
with:
127+
registry: ghcr.io
128+
username: ${{ github.actor }}
129+
password: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Set up Docker Buildx
132+
uses: docker/setup-buildx-action@v3
133+
if: ${{ env.build_needed == 'true' }}
134+
135+
- name: Enable containerd snapshotter for multi-platform builds
136+
uses: depot/use-containerd-snapshotter-action@v1
137+
if: ${{ env.build_needed == 'true' }}
138+
139+
- name: Build and Push Docker Container
140+
if: ${{ env.build_needed == 'true' }}
141+
run: |
142+
image="${{ steps.set_container_tag.outputs.container_image }}"
143+
docker buildx build --platform linux/amd64,linux/arm64 -t ${image} --push .
144+
71145
build_linux_python_lib:
72146
name: Build Python wheels for Linux (${{ matrix.arch.name }})
73-
needs: build_prepare
147+
needs:
148+
- build_prepare
149+
- build_linux_build_container
74150

75151
strategy:
76152
matrix:
77153
arch:
78154
- name: x86_64
79-
container: ghcr.io/project-chip/chip-build:81
80155
runner: ubuntu-22.04
81156
- name: aarch64
82-
container: docker.io/agners/aarch64-chip-build:81
83157
runner: ARM64
84158

85159
runs-on: ${{ matrix.arch.runner }}
@@ -91,7 +165,7 @@ jobs:
91165
working-directory: ./connectedhomeip/
92166

93167
container:
94-
image: ${{ matrix.arch.container }}
168+
image: ${{ needs.build_linux_build_container.outputs.container_image }}
95169
volumes:
96170
- "/tmp/log_output:/tmp/test_logs"
97171
options: --sysctl "net.ipv6.conf.all.disable_ipv6=0

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Based on integrations/docker/images/base/chip-build-minimal/Dockerfile
2+
# Use Debian 12 bookworm and install all required dependencies to build and test
3+
# the Python wheels.
4+
FROM debian:12
5+
LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
6+
7+
RUN set -x \
8+
&& apt-get update \
9+
&& DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
10+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
11+
build-essential \
12+
ca-certificates \
13+
generate-ninja \
14+
git pkg-config \
15+
ninja-build \
16+
python3-venv \
17+
&& git config --global advice.detachedHead false
18+
19+
# CHIP build dependencies
20+
RUN set -x \
21+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
22+
libssl-dev libglib2.0-dev \
23+
libnl-3-dev libnl-route-3-dev \
24+
libcairo2-dev libgirepository1.0-dev \
25+
libdbus-1-dev \
26+
python3-dev

0 commit comments

Comments
 (0)