From 368c0777cd2ee8a0cab18a07891271f803ded54e Mon Sep 17 00:00:00 2001 From: Joel Takvorian Date: Tue, 10 Dec 2024 11:57:57 +0100 Subject: [PATCH] Use correct tag for ghaction builds --- .github/workflows/push_image.yml | 4 ++- .github/workflows/push_image_pr.yml | 2 ++ Makefile | 4 +-- hack/build-bytecode-images-multi.sh | 46 ++++++++++++++++++++--------- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 5e627870d..16f7ee977 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -34,7 +34,9 @@ jobs: - name: get short sha run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: build and push bytecode image - run: make build-and-push-bc-image + run: | + IMAGE_NOO_BC=quay.io/netobserv/ebpf-bytecode:${{ env.WF_VERSION }} make build-and-push-bc-image + IMAGE_NOO_BC=quay.io/netobserv/ebpf-bytecode:${{ env.short_sha }} OCI_BUILD_OPTS="--label quay.expires-after=2w" make build-and-push-bc-image - name: build and push manifest with images run: | MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} CLEAN_BUILD=1 make images diff --git a/.github/workflows/push_image_pr.yml b/.github/workflows/push_image_pr.yml index 93e183f81..40a28d7db 100644 --- a/.github/workflows/push_image_pr.yml +++ b/.github/workflows/push_image_pr.yml @@ -36,6 +36,8 @@ jobs: registry: quay.io - name: get short sha run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: build and push bytecode image + run: IMAGE_NOO_BC=quay.io/netobserv/ebpf-bytecode:${{ env.short_sha }} OCI_BUILD_OPTS="--label quay.expires-after=2w" make build-and-push-bc-image - name: build and push manifest with images run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} CLEAN_BUILD=1 make images - uses: actions/github-script@v6 diff --git a/Makefile b/Makefile index 9e35e9255..807ccdbe9 100644 --- a/Makefile +++ b/Makefile @@ -146,8 +146,8 @@ compile: ## Compile ebpf agent project GOARCH=${GOARCH} GOOS=$(GOOS) go build -mod vendor -a -o bin/netobserv-ebpf-agent cmd/netobserv-ebpf-agent.go .PHONY: build-and-push-bc-image -build-and-push-bc-image: docker-generate ## Build and push bytecode image - IMAGE_NOO_BC=${IMAGE_NOO_BC} ./hack/build-bytecode-images-multi.sh +build-and-push-bc-image: ## Build and push bytecode image + IMAGE_NOO_BC=${IMAGE_NOO_BC} OCI_BIN=${OCI_BIN} OCI_BUILD_OPTS="${OCI_BUILD_OPTS}" ./hack/build-bytecode-images-multi.sh .PHONY: test test: ## Test code using go test diff --git a/hack/build-bytecode-images-multi.sh b/hack/build-bytecode-images-multi.sh index b15621cb9..82dbb7cf7 100755 --- a/hack/build-bytecode-images-multi.sh +++ b/hack/build-bytecode-images-multi.sh @@ -1,7 +1,8 @@ #!/bin/bash # Set default value for IMAGE_NOO_BC tag if not already set -IMAGE_NOO_BC=${IMAGE_NOO_BC:-quay.io/netobserv/ebpf-bytecode} +IMAGE_NOO_BC=${IMAGE_NOO_BC:-quay.io/${USER}/ebpf-bytecode} +OCI_BIN=${OCI_BIN:-docker} # PROGRAMS is a list of : tuples PROGRAMS='{ @@ -29,17 +30,34 @@ MAPS='{ "filter_map":"lpm_trie" }' -docker buildx create --use -docker buildx inspect --bootstrap +if [[ ${OCI_BIN} == "docker" ]]; then + docker buildx create --use + docker buildx inspect --bootstrap -DOCKER_BUILDKIT=1 docker buildx build \ - --platform linux/amd64,linux/arm64,linux/s390x,linux/ppc64le \ - --build-arg PROGRAMS="$PROGRAMS" \ - --build-arg MAPS="$MAPS" \ - --build-arg BC_AMD64_EL=bpf_x86_bpfel.o \ - --build-arg BC_ARM64_EL=bpf_arm64_bpfel.o \ - --build-arg BC_S390X_EB=bpf_s390_bpfeb.o \ - --build-arg BC_PPC64LE_EL=bpf_powerpc_bpfel.o \ - -f ./Containerfile.bytecode.multi.arch \ - --push \ - ./pkg/ebpf -t $IMAGE_NOO_BC + docker buildx build \ + --platform linux/amd64,linux/arm64,linux/s390x,linux/ppc64le \ + --build-arg PROGRAMS="$PROGRAMS" \ + --build-arg MAPS="$MAPS" \ + --build-arg BC_AMD64_EL=bpf_x86_bpfel.o \ + --build-arg BC_ARM64_EL=bpf_arm64_bpfel.o \ + --build-arg BC_S390X_EB=bpf_s390_bpfeb.o \ + --build-arg BC_PPC64LE_EL=bpf_powerpc_bpfel.o \ + ${OCI_BUILD_OPTS} + -f ./Containerfile.bytecode.multi.arch \ + --push \ + ./pkg/ebpf -t $IMAGE_NOO_BC +else + ${OCI_BIN} buildx build \ + --platform linux/amd64,linux/arm64,linux/s390x,linux/ppc64le \ + --build-arg PROGRAMS="$PROGRAMS" \ + --build-arg MAPS="$MAPS" \ + --build-arg BC_AMD64_EL=bpf_x86_bpfel.o \ + --build-arg BC_ARM64_EL=bpf_arm64_bpfel.o \ + --build-arg BC_S390X_EB=bpf_s390_bpfeb.o \ + --build-arg BC_PPC64LE_EL=bpf_powerpc_bpfel.o \ + ${OCI_BUILD_OPTS} + -f ./Containerfile.bytecode.multi.arch \ + ./pkg/ebpf -t $IMAGE_NOO_BC + + ${OCI_BIN} push $IMAGE_NOO_BC +fi