Skip to content

Commit 66b87f7

Browse files
committed
support for linux v5 and v6
1 parent fca1086 commit 66b87f7

6 files changed

Lines changed: 79 additions & 50 deletions

File tree

.github/workflows/build-and-push-noble.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,33 @@ jobs:
3838
- name: Run build.bash
3939
run: |
4040
41-
SNAPSHOT_NAME="noble-ros2-linuxv5-$(date +%Y%m%d%H%M%S)"
41+
if [[ -n "$GITHUB_REF" ]]; then
42+
REF_SLUG="$(echo "$GITHUB_REF" | sed 's|refs/[^/]*/||' | sed 's|/|-|g')"
43+
SNAPSHOT_NAME="noble-ros2-${REF_SLUG}"
44+
else
45+
SNAPSHOT_NAME="noble-ros2-$(date +%Y%m%d%H%M%S)"
46+
fi
4247
echo "SNAPSHOT_NAME=$SNAPSHOT_NAME" >> "$GITHUB_ENV"
48+
49+
PUSH_ARG=""
50+
if [[ "$GITHUB_EVENT_NAME" == "schedule" || "$GITHUB_REF" == refs/tags/v* ]]; then
51+
PUSH_ARG="--push"
52+
fi
4353
4454
export BUILDX_BAKE_ENTITLEMENTS_FS=0
4555
4656
./noble/build.bash \
4757
--user-id 1000 \
4858
--recipes-repo https://github.com/advrhumanoids/multidof_recipes.git \
4959
--recipes-tag ros2 \
50-
--kernel-ver 5 \
5160
--forest-njobs 4 \
5261
--netrc ~/.netrc \
5362
--no-cache \
63+
$PUSH_ARG \
5464
--snapshot \
5565
--snapshot-name "$SNAPSHOT_NAME"
5666
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/v') || contains(env.COMMIT_MESSAGE, '[build noble]')
5767

58-
- name: Run push.sh
59-
run: ./noble/push.bash --tag "$SNAPSHOT_NAME"
60-
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/v')
61-
6268
- name: Archive snapshot
6369
run: tar -czf snapshot-${{ env.SNAPSHOT_NAME }}.tar.gz -C noble/snapshots ${{ env.SNAPSHOT_NAME }}
6470
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/v') || contains(env.COMMIT_MESSAGE, '[build noble]')
@@ -67,7 +73,7 @@ jobs:
6773
id: prev_snapshot
6874
run: |
6975
URL=$(gh api "repos/${{ github.repository }}/releases" \
70-
--jq 'map(select(.tag_name | startswith("noble-ros2-linuxv5-"))) | first | .assets[] | select(.name | startswith("snapshot-")) | .browser_download_url' \
76+
--jq 'map(select(.tag_name | startswith("noble-ros2-rt-v5-v6-"))) | first | .assets[] | select(.name | startswith("snapshot-")) | .browser_download_url' \
7177
2>/dev/null || true)
7278
echo "url=${URL}" >> "$GITHUB_OUTPUT"
7379
env:

noble/build.bash

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ RECIPES_REPO=""
99
RECIPES_TAG=""
1010
FOREST_NJOBS="1"
1111
NETRC_FILE=""
12-
TAG="latest"
13-
KERNEL_VER=""
12+
TAG="${TAG:-${GITHUB_REF_NAME:-latest}}"
1413
NO_CACHE=""
14+
PUSH=""
1515
SNAPSHOT=""
1616
SNAPSHOT_NAME="$(date +%Y%m%d%H%M)"
1717

@@ -20,17 +20,17 @@ usage() {
2020
cat <<EOF
2121
Usage: $(basename "$0") [OPTIONS]
2222
23-
Build the xbot2 noble Docker images (base -> robot -> rt) using docker buildx bake.
23+
Build the xbot2 noble Docker images (base -> robot -> rt-v5/rt-v6) using docker buildx bake.
2424
2525
Options:
2626
--user-id ID UID for the 'user' account inside the container (default: current user)
2727
--recipes-repo URL Forest recipes repository URL [required for robot/rt]
2828
--recipes-tag TAG Forest recipes git tag/branch [required for robot/rt]
2929
--forest-njobs N Parallel jobs for forest grow (default: 1)
3030
--netrc PATH Path to a .netrc file for private git clones (build secret)
31-
--tag TAG Docker image tag applied to all three images (default: latest)
32-
--kernel-ver VER Kernel version passed to Dockerfile-rt as KERNEL_VER
31+
--tag TAG Docker image tag applied to all images (default: TAG, GITHUB_REF_NAME, or latest)
3332
--no-cache Pass --no-cache to docker buildx bake
33+
--push Push images to the registry instead of only loading them locally
3434
--snapshot Run snapshot.bash after a successful build
3535
--snapshot-name NAME Build name subfolder for the snapshot (default: YYYYMMDDHHmm)
3636
-h, --help Show this help message
@@ -46,8 +46,8 @@ while [[ $# -gt 0 ]]; do
4646
--forest-njobs) FOREST_NJOBS="$2"; shift 2 ;;
4747
--netrc) NETRC_FILE="$2"; shift 2 ;;
4848
--tag) TAG="$2"; shift 2 ;;
49-
--kernel-ver) KERNEL_VER="$2"; shift 2 ;;
5049
--no-cache) NO_CACHE="--no-cache"; shift ;;
50+
--push) PUSH="1"; shift ;;
5151
--snapshot) SNAPSHOT="1"; shift ;;
5252
--snapshot-name) SNAPSHOT_NAME="$2"; shift 2 ;;
5353
-h|--help) usage; exit 0 ;;
@@ -62,7 +62,6 @@ export RECIPES_TAG
6262
export FOREST_NJOBS
6363
export NETRC_FILE
6464
export TAG
65-
export KERNEL_VER
6665

6766
cd "$DIR"
6867

@@ -71,8 +70,30 @@ if [[ -n "$SNAPSHOT" && "$TAG" == "latest" ]]; then
7170
TAG="$SNAPSHOT_NAME"
7271
fi
7372

74-
docker buildx bake --allow=fs.read=$(realpath "$NETRC_FILE") -f docker-bake.hcl --load $NO_CACHE
73+
BAKE_ARGS=(-f docker-bake.hcl)
74+
if [[ -n "$NETRC_FILE" ]]; then
75+
BAKE_ARGS=(--allow=fs.read="$(realpath "$NETRC_FILE")" "${BAKE_ARGS[@]}")
76+
fi
77+
NO_CACHE_ARGS=()
78+
if [[ -n "$NO_CACHE" ]]; then
79+
NO_CACHE_ARGS+=("$NO_CACHE")
80+
fi
7581

7682
if [[ -n "$SNAPSHOT" ]]; then
83+
echo "Building images locally with tag: $TAG"
84+
docker buildx bake "${BAKE_ARGS[@]}" "${NO_CACHE_ARGS[@]}" --load rt
85+
7786
"$DIR/snapshot.bash" --tag "$TAG" --name "$SNAPSHOT_NAME"
7887
fi
88+
89+
if [[ -n "$PUSH" ]]; then
90+
echo "Building and pushing images with tag: $TAG"
91+
PUSH_NO_CACHE_ARGS=()
92+
if [[ -z "$SNAPSHOT" ]]; then
93+
PUSH_NO_CACHE_ARGS=("${NO_CACHE_ARGS[@]}")
94+
fi
95+
docker buildx bake "${BAKE_ARGS[@]}" "${PUSH_NO_CACHE_ARGS[@]}" --push rt
96+
elif [[ -z "$SNAPSHOT" ]]; then
97+
echo "Building images locally with tag: $TAG"
98+
docker buildx bake "${BAKE_ARGS[@]}" "${NO_CACHE_ARGS[@]}" --load rt
99+
fi

noble/compose.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ services:
3535
extends: dev-nvidia
3636
image: hhcmhub/xbot2-noble-robot:latest
3737

38-
rt:
38+
rt-v5:
3939
extends: dev
40-
image: hhcmhub/xbot2-noble-rt:latest
40+
image: hhcmhub/xbot2-noble-rt-v5:latest
4141

42-
42+
rt-v6:
43+
extends: dev
44+
image: hhcmhub/xbot2-noble-rt-v6:latest
4345

46+
rt:
47+
extends: rt-v6
4448

noble/docker-bake.hcl

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ variable "TAG" {
3030
default = "latest"
3131
}
3232

33-
variable "KERNEL_VER" {
34-
default = ""
35-
}
36-
3733
# ----- Targets -----
3834

3935
group "default" {
40-
targets = ["base", "robot", "rt"]
36+
targets = ["base", "robot", "rt-v5", "rt-v6"]
37+
}
38+
39+
group "rt" {
40+
targets = ["base", "robot", "rt-v5", "rt-v6"]
4141
}
4242

4343
target "base" {
@@ -46,7 +46,7 @@ target "base" {
4646
args = {
4747
USER_ID = USER_ID
4848
}
49-
tags = ["hhcmhub/xbot2-noble-dev:${TAG}"]
49+
tags = TAG != "latest" ? ["hhcmhub/xbot2-noble-dev:${TAG}", "hhcmhub/xbot2-noble-dev:latest"] : ["hhcmhub/xbot2-noble-dev:latest"]
5050
}
5151

5252
target "robot" {
@@ -64,10 +64,10 @@ target "robot" {
6464
USER_ID = USER_ID
6565
}
6666
secret = NETRC_FILE != "" ? ["id=netrc,src=${NETRC_FILE}"] : []
67-
tags = ["hhcmhub/xbot2-noble-robot:${TAG}"]
67+
tags = TAG != "latest" ? ["hhcmhub/xbot2-noble-robot:${TAG}", "hhcmhub/xbot2-noble-robot:latest"] : ["hhcmhub/xbot2-noble-robot:latest"]
6868
}
6969

70-
target "rt" {
70+
target "rt-common" {
7171
dockerfile = "Dockerfile-rt"
7272
context = "."
7373
depends_on = ["robot"]
@@ -80,8 +80,22 @@ target "rt" {
8080
RECIPES_TAG = RECIPES_TAG
8181
FOREST_NJOBS = FOREST_NJOBS
8282
USER_ID = USER_ID
83-
KERNEL_VER = KERNEL_VER
8483
}
8584
secret = NETRC_FILE != "" ? ["id=netrc,src=${NETRC_FILE}"] : []
86-
tags = ["hhcmhub/xbot2-noble-rt:${TAG}"]
85+
}
86+
87+
target "rt-v5" {
88+
inherits = ["rt-common"]
89+
args = {
90+
KERNEL_VER = "5"
91+
}
92+
tags = TAG != "latest" ? ["hhcmhub/xbot2-noble-rt-v5:${TAG}", "hhcmhub/xbot2-noble-rt-v5:latest"] : ["hhcmhub/xbot2-noble-rt-v5:latest"]
93+
}
94+
95+
target "rt-v6" {
96+
inherits = ["rt-common"]
97+
args = {
98+
KERNEL_VER = "6"
99+
}
100+
tags = TAG != "latest" ? ["hhcmhub/xbot2-noble-rt-v6:${TAG}", "hhcmhub/xbot2-noble-rt-v6:latest"] : ["hhcmhub/xbot2-noble-rt-v6:latest"]
87101
}

noble/push.bash

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

noble/snapshot.bash

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ usage() {
1212
cat <<EOF
1313
Usage: $(basename "$0") [OPTIONS]
1414
15-
Extract software version snapshots from the three built xbot2 noble images.
16-
Snapshots are saved under snapshots/<BUILD_NAME>/{base,robot,rt}/.
15+
Extract software version snapshots from the built xbot2 noble images.
16+
Snapshots are saved under snapshots/<BUILD_NAME>/{base,robot,rt-v5,rt-v6}/.
1717
1818
Options:
1919
--tag TAG Docker image tag to snapshot (default: latest)
@@ -83,10 +83,12 @@ extract_image() {
8383
# ----- Extract from each image -----
8484
extract_image "hhcmhub/xbot2-noble-dev:${TAG}" "$SNAPSHOT_DIR/base" 0
8585
extract_image "hhcmhub/xbot2-noble-robot:${TAG}" "$SNAPSHOT_DIR/robot" 1
86-
extract_image "hhcmhub/xbot2-noble-rt:${TAG}" "$SNAPSHOT_DIR/rt" 1
86+
extract_image "hhcmhub/xbot2-noble-rt-v5:${TAG}" "$SNAPSHOT_DIR/rt-v5" 1
87+
extract_image "hhcmhub/xbot2-noble-rt-v6:${TAG}" "$SNAPSHOT_DIR/rt-v6" 1
8788

8889
echo ""
8990
echo "Snapshot complete: $SNAPSHOT_DIR"
9091
echo " base/ image-digest.txt apt-sources.txt apt.txt pip.txt"
9192
echo " robot/ image-digest.txt apt-sources.txt apt.txt pip.txt forest.lock"
92-
echo " rt/ image-digest.txt apt-sources.txt apt.txt pip.txt forest.lock"
93+
echo " rt-v5/ image-digest.txt apt-sources.txt apt.txt pip.txt forest.lock"
94+
echo " rt-v6/ image-digest.txt apt-sources.txt apt.txt pip.txt forest.lock"

0 commit comments

Comments
 (0)