Skip to content

Commit 1099434

Browse files
committed
Justfile: Add a label for locally built images and cleanup helper
To make it easeier to clean things up.
1 parent d596a32 commit 1099434

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Justfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
variant := env("BOOTC_variant", "ostree")
1717
base := env("BOOTC_base", "quay.io/centos-bootc/centos-bootc:stream10")
1818

19+
testimage_label := "bootc.testimage=1"
20+
base_buildargs := "--jobs 4 --label=" + testimage_label
1921
buildargs := "--build-arg=base=" + base + " --build-arg=variant=" + variant
2022

2123
# Build the container image from current sources.
2224
# Note commonly you might want to override the base image via e.g.
2325
# `just build --build-arg=base=quay.io/fedora/fedora-bootc:42`
2426
build:
25-
podman build --jobs=4 -t localhost/bootc-bin {{buildargs}} .
27+
podman build {{base_buildargs}} -t localhost/bootc-bin {{buildargs}} .
2628
./tests/build-sealed {{variant}} localhost/bootc-bin localhost/bootc
2729

2830
# This container image has additional testing content and utilities
2931
build-integration-test-image: build
30-
cd hack && podman build --jobs=4 -t localhost/bootc-integration-bin {{buildargs}} -f Containerfile .
32+
cd hack && podman build {{base_buildargs}} -t localhost/bootc-integration-bin {{buildargs}} -f Containerfile .
3133
./tests/build-sealed {{variant}} localhost/bootc-integration-bin localhost/bootc-integration
3234
# Keep these in sync with what's used in hack/lbi
3335
podman pull -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest
@@ -43,7 +45,7 @@ test-composefs:
4345

4446
# Only used by ci.yml right now
4547
build-install-test-image: build-integration-test-image
46-
cd hack && podman build -t localhost/bootc-integration-install -f Containerfile.drop-lbis
48+
cd hack && podman build {{base_buildargs}} -t localhost/bootc-integration-install -f Containerfile.drop-lbis
4749

4850
build-disk-image container target:
4951
bcvk to-disk --format=qcow2 --disk-size 20G --filesystem ext4 {{container}} {{target}}
@@ -54,11 +56,11 @@ run-container-external-tests:
5456

5557
# We build the unit tests into a container image
5658
build-units:
57-
podman build --jobs=4 --target units -t localhost/bootc-units .
59+
podman build {{base_buildargs}} --target units -t localhost/bootc-units .
5860

5961
# Perform validation (build, linting) in a container build environment
6062
validate:
61-
podman build --jobs=4 --target validate .
63+
podman build {{base_buildargs}} --target validate .
6264

6365
# Directly run validation (build, linting) using host tools
6466
validate-local:
@@ -86,12 +88,17 @@ test-container: build-units build-integration-test-image
8688
# Pass these through for cross-checking
8789
podman run --rm --env=BOOTC_variant={{variant}} --env=BOOTC_base={{base}} localhost/bootc-integration bootc-integration-tests container
8890

91+
# Remove all container images built (locally) via this Justfile, by matching a label
92+
clean-local-images:
93+
podman images --filter "label={{testimage_label}}"
94+
podman images --filter "label={{testimage_label}}" --format "{{{{.ID}}" | xargs -r podman rmi -f
95+
8996
# Print the container image reference for a given short $ID-VERSION_ID
9097
pullspec-for-os NAME:
9198
@jq -r --arg v "{{NAME}}" '.[$v]' < hack/os-image-map.json
9299

93100
build-mdbook:
94-
cd docs && podman build -t localhost/bootc-mdbook -f Dockerfile.mdbook
101+
cd docs && podman build {{base_buildargs}} -t localhost/bootc-mdbook -f Dockerfile.mdbook
95102

96103
# Generate the rendered HTML to the target DIR directory
97104
build-mdbook-to DIR: build-mdbook

0 commit comments

Comments
 (0)