diff --git a/.github/workflows/package-apisix-fedora-rpm.yml b/.github/workflows/package-apisix-fedora-rpm.yml new file mode 100644 index 000000000..b5f51a47f --- /dev/null +++ b/.github/workflows/package-apisix-fedora-rpm.yml @@ -0,0 +1,39 @@ +name: package apisix rpm for Fedora 34 + +on: + push: + branches: [ master ] + tags: + - "v*" + paths-ignore: + - '*.md' + pull_request: + branches: [ master ] + paths-ignore: + - '*.md' + schedule: + - cron: '0 0 * * *' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: install dependencies + run: | + sudo apt-get install -y make + + - name: run apisix packaging + run: | + make package type=rpm app=apisix_fedora version=master checkout=master image_base=fedora image_tag=34 artifact=apisix-remote + make package type=rpm app=apisix_fedora version=2.2 checkout=2.2 image_base=fedora image_tag=34 + + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: apisix-2.2-0.fedora34.x86_64.rpm + path: output/apisix-2.2-0.fedora34.x86_64.rpm + retention-days: 5 + if-no-files-found: error diff --git a/Makefile b/Makefile index 98d18fcb4..53fb13af0 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,17 @@ else $(call build,apisix,apisix,rpm,$(local_code_path)) endif +### build apisix_fedora: +.PHONY: build-apisix_fedora-rpm +build-apisix_fedora-rpm: +ifeq ($(local_code_path), 0) + git clone -b $(checkout) $(apisix_repo) ./apisix + $(call build,apisix,apisix_fedora,rpm,"./apisix") + rm -fr ./apisix +else + $(call build,apisix,apisix_fedora,rpm,$(local_code_path)) +endif + .PHONY: build-apisix-deb build-apisix-deb: ifeq ($(local_code_path), 0) @@ -111,6 +122,10 @@ endif package-apisix-rpm: $(call package,apisix,rpm) +.PHONY: package-apisix_fedora-rpm +package-apisix_fedora-rpm: + $(call package,apisix_fedora,rpm) + .PHONY: package-apisix-deb package-apisix-deb: $(call package,apisix,deb) @@ -179,8 +194,8 @@ build-fpm: -t api7/fpm - < ./dockerfiles/Dockerfile.fpm endif -ifeq ($(filter $(app),apisix dashboard apisix-base),) -$(info the app's value have to be apisix or dashboard!) +ifeq ($(filter $(app),apisix_fedora apisix dashboard apisix-base),) +$(info the app's value have to be apisix_fedora, apisix or dashboard!) else ifeq ($(filter $(type),rpm deb),) $(info the type's value have to be rpm or deb!) @@ -206,6 +221,12 @@ package: build-fpm package: build-apisix-rpm package: package-apisix-rpm + +else ifeq ($(app)_$(type),apisix_fedora_rpm) +package: build-fpm +package: build-apisix_fedora-rpm +package: package-apisix_fedora-rpm + else ifeq ($(app)_$(type),apisix_deb) package: build-fpm package: build-apisix-deb @@ -221,4 +242,4 @@ package: build-fpm package: build-dashboard-deb package: package-dashboard-deb -endif +endif \ No newline at end of file diff --git a/README.md b/README.md index 2eecb4932..9bac45141 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ make package type=rpm app=apisix version=2.2 checkout=2.2 image_base=centos imag ls output/ apisix-2.2-0.el8.x86_64.rpm ``` +Packaging a Fedora 34 package of Apache APISIX +```sh +make package type=rpm app=apisix_fedora version=2.2 checkout=2.2 image_base=fedora image_tag=34 +ls output/ +apisix-2.2-0.fedora34.x86_64.rpm +``` Packaging an Ubuntu 20.04 package of Apache APISIX ```sh diff --git a/dockerfiles/Dockerfile.apisix_fedora.rpm b/dockerfiles/Dockerfile.apisix_fedora.rpm new file mode 100644 index 000000000..920b81ba0 --- /dev/null +++ b/dockerfiles/Dockerfile.apisix_fedora.rpm @@ -0,0 +1,30 @@ +ARG IMAGE_BASE="fedora" +ARG IMAGE_TAG="34" + +FROM ${IMAGE_BASE}:${IMAGE_TAG} + +COPY ./utils/install-common.sh /install-common.sh +COPY ./utils/determine-dist.sh /determine-dist.sh + +ARG iteration="0" +ARG apisix_repo="https://github.com/apache/apisix" +ARG checkout_v +ARG IMAGE_BASE +ARG IMAGE_TAG +ARG CODE_PATH + +# install dependencies +RUN /install-common.sh install_apisix_fedora_dependencies_rpm + +ENV checkout_v=${checkout_v} +ENV iteration=${iteration} +ENV apisix_repo=${apisix_repo} +ENV IMAGE_BASE=${IMAGE_BASE} +ENV IMAGE_TAG=${IMAGE_TAG} + +COPY ${CODE_PATH} /apisix + +# install apisix +RUN /install-common.sh install_apisix \ + # determine dist and write it into /tmp/dist file + && /determine-dist.sh \ No newline at end of file diff --git a/dockerfiles/Dockerfile.package.apisix_fedora b/dockerfiles/Dockerfile.package.apisix_fedora new file mode 100644 index 000000000..3271e8556 --- /dev/null +++ b/dockerfiles/Dockerfile.package.apisix_fedora @@ -0,0 +1,24 @@ +ARG VERSION +ARG PACKAGE_TYPE + +FROM apache/apisix-${PACKAGE_TYPE}:${VERSION} AS APISIX_FEDORA +FROM api7/fpm + +ARG ITERATION +ARG PACKAGE_VERSION +ARG PACKAGE_TYPE +ARG OPENRESTY +ARG ARTIFACT + +ENV ITERATION=${ITERATION} +ENV PACKAGE_VERSION=${PACKAGE_VERSION} +ENV PACKAGE_TYPE=${PACKAGE_TYPE} +ENV OPENRESTY=${OPENRESTY} +ENV ARTIFACT=${ARTIFACT} + +COPY --from=APISIX_FEDORA /tmp/build/output /tmp/build/output +COPY --from=APISIX_FEDORA /tmp/dist /tmp/dist +COPY package-apisix.sh /package-apisix.sh +COPY usr /usr + +RUN /package-apisix.sh \ No newline at end of file diff --git a/package-apisix.sh b/package-apisix.sh index 599175508..9534e5dac 100755 --- a/package-apisix.sh +++ b/package-apisix.sh @@ -22,7 +22,7 @@ fi # Determine the name of artifact # The defaut is apisix -artifact="apisix" +artifact="apisix" if [ "$ARTIFACT" != "0" ] then artifact=${ARTIFACT} diff --git a/utils/determine-dist.sh b/utils/determine-dist.sh index 3441fc4a2..a26fa12cd 100755 --- a/utils/determine-dist.sh +++ b/utils/determine-dist.sh @@ -6,9 +6,11 @@ dist="el7" if [ "${IMAGE_BASE}" == "centos" ] then dist="el${IMAGE_TAG}" +elif [ "${IMAGE_BASE}" == "fedora" ] +then + dist="${IMAGE_BASE}${IMAGE_TAG}" elif [ "${IMAGE_BASE}" == "ubuntu" ] then dist="${IMAGE_BASE}${IMAGE_TAG}" fi - -echo "${dist}" > /tmp/dist +echo "${dist}" > /tmp/dist \ No newline at end of file diff --git a/utils/install-common.sh b/utils/install-common.sh index 6507badc3..bad5ed00c 100755 --- a/utils/install-common.sh +++ b/utils/install-common.sh @@ -14,16 +14,29 @@ install_apisix_dependencies_rpm() { install_luarocks } +install_apisix_fedora_dependencies_rpm() { + install_fedora_dependencies_rpm + install_fedora_openresty_rpm + install_luarocks +} + install_dependencies_rpm() { # install basic dependencies yum -y install wget tar gcc automake autoconf libtool make curl git which unzip yum -y install epel-release yum install -y yum-utils readline-dev readline-devel + # install lua 5.1 for compatible with openresty 1.17.8.2 + install_lua +} +install_fedora_dependencies_rpm() { + # install basic dependencies + yum -y install tar ccache make gcc libtool git unzip which autoconf automake readline-devel wget # install lua 5.1 for compatible with openresty 1.17.8.2 install_lua } + install_dependencies_deb() { # install basic dependencies DEBIAN_FRONTEND=noninteractive apt-get update @@ -58,6 +71,12 @@ install_openresty_rpm() { yum install -y openresty openresty-openssl111-devel pcre pcre-devel } +install_fedora_openresty_rpm() { + sudo dnf install -y dnf-plugins-core + sudo dnf config-manager --add-repo https://openresty.org/package/fedora/openresty.repo + yum install -y openresty openresty-openssl111-devel pcre pcre-devel +} + install_luarocks() { # install luarocks wget https://github.com/luarocks/luarocks/archive/v3.4.0.tar.gz @@ -163,6 +182,9 @@ case ${case_opt} in install_apisix_dependencies_rpm) install_apisix_dependencies_rpm ;; +install_apisix_fedora_dependencies_rpm) + install_apisix_fedora_dependencies_rpm + ;; install_apisix_dependencies_deb) install_apisix_dependencies_deb ;; @@ -187,4 +209,4 @@ install_dashboard_dependencies_deb) install_dashboard) install_dashboard ;; -esac +esac \ No newline at end of file