From 4c58b6959e5abdc7ea2a484b88c0897c06bc51c6 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 20 Aug 2024 13:57:14 +0530 Subject: [PATCH] ci: add manual trigger to release apisix-runtime debian package (#399) * ci: add manual trigger to build apisix-runtime debian package (#396) * ci: add manual trigger to build apisix-runtime debian package * rename * install dependencies * rename * change arch * change * use env.ARCH * set github env * add image arch * set default * use arch everywhere * use arm64v8 image * use linux/arm64 * use matrix.platform * fix * use same image diff platform * fix * use image name * use debian not ubuntu * a * make release * add tag name * use matrix.platform.arch * Update package-apisix-runtime-deb-openresty-1.21.yml (#398) - change tag name - add pull_request trigger * Update package-apisix-runtime-deb-openresty-1.21.yml (#400) * Update package-apisix-runtime-deb-openresty-1.21.yml (#401) --- ...kage-apisix-runtime-deb-openresty-1.21.yml | 55 +++++++++++++++++++ Makefile | 14 ++++- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/package-apisix-runtime-deb-openresty-1.21.yml diff --git a/.github/workflows/package-apisix-runtime-deb-openresty-1.21.yml b/.github/workflows/package-apisix-runtime-deb-openresty-1.21.yml new file mode 100644 index 000000000..e140ab2c0 --- /dev/null +++ b/.github/workflows/package-apisix-runtime-deb-openresty-1.21.yml @@ -0,0 +1,55 @@ +name: package apisix-runtime deb for debianbullseye-slim with openresty 1.21 + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name for the release' + required: true + default: '' + +jobs: + build: + timeout-minutes: 60 + env: + BUILD_APISIX_RUNTIME_VERSION: 1.1.3 + strategy: + matrix: + platform: + - runner: ubuntu-22.04 + arch: amd64 + - runner: buildjet-2vcpu-ubuntu-2204-arm + arch: arm64 + runs-on: ${{ matrix.platform.runner }} + steps: + - uses: actions/checkout@v2 + with: + ref: openresty/1.21.4 + + - name: Check arch + run: | + echo "ARCH: ${{ matrix.platform.arch }}" + + - name: Install dependencies + run: | + sudo apt-get install -y make ruby ruby-dev rubygems build-essential + + - name: Build apisix-runtime deb + run: | + if [ "${{ matrix.platform.arch }}" == "arm64" ]; then + make package type=deb app=apisix-runtime runtime_version=${BUILD_APISIX_RUNTIME_VERSION} image_base=debian image_tag=bullseye-slim arch=linux/arm64/v8 + else + make package type=deb app=apisix-runtime runtime_version=${BUILD_APISIX_RUNTIME_VERSION} image_base=debian image_tag=bullseye-slim arch=linux/amd64 + fi + + - name: Release with Notes + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.inputs.tag_name }} + body: | + Release apisix-runtime ${{ github.event.inputs.tag_name }} + files: | + ./output/apisix-runtime_${{ env.BUILD_APISIX_RUNTIME_VERSION }}-0~debianbullseye-slim_${{ matrix.platform.arch }}.deb + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/Makefile b/Makefile index ac2481012..3bcd504a8 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ ifeq ($(type), deb) image_base="ubuntu" image_tag="20.04" endif - +# Set arch to linux/amd64 if it's not defined +arch ?= linux/amd64 buildx=0 cache_from=type=local,src=/tmp/.buildx-cache cache_to=type=local,dest=/tmp/.buildx-cache @@ -54,6 +55,7 @@ define build --build-arg IMAGE_BASE=$(image_base) \ --build-arg IMAGE_TAG=$(image_tag) \ --build-arg CODE_PATH=$(4) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -69,6 +71,7 @@ define build --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -87,6 +90,7 @@ define build_runtime --build-arg IMAGE_BASE=$(image_base) \ --build-arg IMAGE_TAG=$(image_tag) \ --build-arg CODE_PATH=$(4) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -101,6 +105,7 @@ define build_runtime --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -118,6 +123,7 @@ define build-image --build-arg OPENRESTY_NAME=$(4) \ --build-arg OPENRESTY_VERSION=$(5) \ --build-arg CODE_PATH=$(6) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef else @@ -129,6 +135,7 @@ define build-image --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.$(2).$(3) . endef endif @@ -145,6 +152,7 @@ define package --build-arg PACKAGE_TYPE=$(2) \ --build-arg OPENRESTY=$(openresty) \ --build-arg ARTIFACT=$(artifact) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.package.$(1) . docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(version) docker cp output:/output ${PWD} @@ -164,6 +172,7 @@ define package_runtime --build-arg PACKAGE_TYPE=$(2) \ --build-arg OPENRESTY=$(openresty) \ --build-arg ARTIFACT=$(artifact) \ + --platform $(arch) \ -f ./dockerfiles/Dockerfile.package.$(1) . docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(runtime_version) docker cp output:/output ${PWD} @@ -290,13 +299,14 @@ package-apisix-base-deb: .PHONY: build-fpm ifneq ($(buildx), True) build-fpm: - docker build -t api7/fpm - < ./dockerfiles/Dockerfile.fpm + docker build --platform $(arch) -t api7/fpm - < ./dockerfiles/Dockerfile.fpm else build-fpm: docker buildx build \ --load \ --cache-from=$(cache_from) \ --cache-to=$(cache_to) \ + --platform $(arch) \ -t api7/fpm - < ./dockerfiles/Dockerfile.fpm endif