Skip to content

Commit 223f80c

Browse files
ycardaillacbasejump-app
authored andcommitted
docker-tag-native.bb: add recipe
this package helps making sense of docker image builded by yocto, they are now automatically tagged with: balenaos-${MACHINE}-${BASENAME}:latest balenaos-${MACHINE}-${BASENAME}:$(date +%Y%m%d%H%M%S) Change-type: patch Signed-off-by: Yann CARDAILLAC <[email protected]>
1 parent 74f3bfc commit 223f80c

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

meta-balena-common/classes/image_types_balena.bbclass

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,15 @@ IMAGE_CMD:balenaos-img () {
384384
# partition
385385
do_rootfs[vardeps] += "BALENA_BOOT_PARTITION_FILES"
386386

387+
do_image_docker[depends] = " \
388+
docker-tag-native:do_populate_sysroot \
389+
"
390+
387391
# XXX(petrosagg): This should be eventually implemented using a docker-native daemon
388392
IMAGE_CMD:docker () {
389393
DOCKER_IMAGE=$(${IMAGE_CMD_TAR} -cv -C ${IMAGE_ROOTFS} . | DOCKER_API_VERSION=${BALENA_API_VERSION} docker import -)
390394
DOCKER_API_VERSION=${BALENA_API_VERSION} docker save ${DOCKER_IMAGE} > ${BALENA_DOCKER_IMG}
395+
docker-tag-native "${DOCKER_IMAGE}" "${MACHINE}" "${IMAGE_BASENAME}"
391396
}
392397

393398
IMAGE_TYPEDEP:hostapp-ext4 = "docker"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DESCRIPTION = "Helper tool to tag imported docker images"
2+
LICENSE = "Apache-2.0"
3+
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
4+
5+
inherit native
6+
7+
SRC_URI = "file://docker-tag-native.sh"
8+
9+
S = "${WORKDIR}"
10+
11+
do_install() {
12+
install -d ${D}${bindir}
13+
install -m 0755 ${WORKDIR}/docker-tag-native.sh ${D}${bindir}/docker-tag-native
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# Usage: docker-tag-wrapper <image-id> <machine> <basename>
3+
4+
set -eu
5+
6+
IMAGE_ID="$1"
7+
MACHINE="$2"
8+
BASENAME="$3"
9+
10+
BASE_TAG="balenaos-${MACHINE}-${BASENAME}:latest"
11+
DATE_TAG="balenaos-${MACHINE}-${BASENAME}:$(date +%Y%m%d%H%M%S)"
12+
13+
echo "[docker-tag-wrapper] tagging ${IMAGE_ID} -> ${BASE_TAG}, ${DATE_TAG}"
14+
15+
docker tag "${IMAGE_ID}" "${BASE_TAG}"
16+
docker tag "${IMAGE_ID}" "${DATE_TAG}"

0 commit comments

Comments
 (0)