Skip to content

feat: add apisix fedora support #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/package-apisix-fedora-rpm.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +30 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
make package type=rpm app=apisix version=master checkout=master image_base=fedora image_tag=34 artifact=apisix-remote
make package type=rpm app=apisix version=2.2 checkout=2.2 image_base=fedora image_tag=34

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kushal-kothari we would better to keep using apisix here.


- name: Publish Artifact
uses: actions/[email protected]
with:
name: apisix-2.2-0.fedora34.x86_64.rpm
path: output/apisix-2.2-0.fedora34.x86_64.rpm
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: apisix-2.2-0.fedora34.x86_64.rpm
path: output/apisix-2.2-0.fedora34.x86_64.rpm
name: apisix-2.2-0.fc34.x86_64.rpm
path: output/apisix-2.2-0.fc34.x86_64.rpm

retention-days: 5
if-no-files-found: error
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Comment on lines +101 to +109
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kushal-kothari how about reusing build-apisix-rpm here, and check if the image_base is fedora to decide where to go then?

.PHONY: build-apisix-deb
build-apisix-deb:
ifeq ($(local_code_path), 0)
Expand All @@ -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)
Expand Down Expand Up @@ -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),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kushal-kothari there's no need to add this cause we still use apisix here.

$(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!)
Expand All @@ -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
Expand All @@ -221,4 +242,4 @@ package: build-fpm
package: build-dashboard-deb
package: package-dashboard-deb

endif
endif
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions dockerfiles/Dockerfile.apisix_fedora.rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG IMAGE_BASE="fedora"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how about reusing Dockerfile.apisix.rpm here, without adding this new file? Thanks.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would better add an extra line here. Thanks.

24 changes: 24 additions & 0 deletions dockerfiles/Dockerfile.package.apisix_fedora
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra new line is needed here. Thanks.

2 changes: 1 addition & 1 deletion package-apisix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi

# Determine the name of artifact
# The defaut is apisix
artifact="apisix"
artifact="apisix"
if [ "$ARTIFACT" != "0" ]
then
artifact=${ARTIFACT}
Expand Down
6 changes: 4 additions & 2 deletions utils/determine-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the rpm in Fedora 34, the conventional dist is fc34, instead of fedora34. Thanks.

elif [ "${IMAGE_BASE}" == "ubuntu" ]
then
dist="${IMAGE_BASE}${IMAGE_TAG}"
fi

echo "${dist}" > /tmp/dist
echo "${dist}" > /tmp/dist
24 changes: 23 additions & 1 deletion utils/install-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, we can check if the environment key IMAGE_BASE is fedora, then we could know which function we should call. What do you think?

# 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand All @@ -187,4 +209,4 @@ install_dashboard_dependencies_deb)
install_dashboard)
install_dashboard
;;
esac
esac