Skip to content
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

feat: add build-apisix-openresty-rpm #40

Merged
merged 16 commits into from
Jun 9, 2021
Merged
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
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,34 @@ package-dashboard-rpm:

rm -rf ${PWD}/build

ifeq ($(filter $(app),apisix dashboard),)
### build apisix-openresty:
.PHONY: build-apisix-openresty-rpm
build-apisix-openresty-rpm:
mkdir -p ${PWD}/build/rpm
docker build -t apache/apisix-openresty:$(version) -f ./dockerfiles/Dockerfile.apisix-openresty.rpm .
docker run -d --name dockerInstance --net="host" apache/apisix-openresty:$(version)
docker cp dockerInstance:/usr/local/openresty/ ${PWD}/build/rpm
docker system prune -a -f

### build rpm for apisix-openresty:
.PHONY: package-apisix-openresty-rpm
package-apisix-openresty-rpm:
fpm -f -s dir -t rpm \
-n apisix-openresty \
-a `uname -i` \
-v $(version) \
tzssangglass marked this conversation as resolved.
Show resolved Hide resolved
--iteration $(iteration) \
--description "APISIX's OpenResty distribution." \
--license "ASL 2.0" \
-C ${PWD}/build/rpm \
-p ${PWD}/output/ \
--url 'http://apisix.apache.org/' \
--conflicts openresty \
--config-files usr/lib/systemd/system/openresty.service \
Copy link
Contributor

Choose a reason for hiding this comment

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

@moonming
When we use a file from OpenResty's repo, how do we clarify the license?

--prefix=/usr/local
rm -rf ${PWD}/build

ifeq ($(filter $(app),apisix dashboard apisix-openresty),)
$(info the app's value have to be apisix or dashboard!)

else ifeq ($(filter $(type),rpm deb),)
Expand All @@ -85,6 +112,10 @@ $(info the type's value have to be rpm or deb!)
else ifeq ($(version), 0)
$(info you have to input a version value!)

else ifeq ($(app)_$(type),apisix-openresty_rpm)
package: build-apisix-openresty-rpm
package: package-apisix-openresty-rpm

else ifeq ($(checkout), 0)
$(info you have to input a checkout value!)

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
|Parameter |Required |Description |Example|
|---------|---------|----|-----------|
|type |True |it can be `deb` or `rpm` |type=rpm|
|app |True |it can be `apisix` or `dashboard` |app=apisix|
|app |True |it can be `apisix`, `dashboard` or `apisix-openresty`|app=apisix|
|checkout |True |the code branch or tag of the app which you want to package|checkout=2.1 or checkout=v2.1|
|version |True |the version of the package|version=10.10|
|image_base|False |the environment for packaging, if type is `rpm` the default image_base is `centos`, if type is `deb` the default image_base is `ubuntu`|image_base=centos|
Expand All @@ -30,6 +30,13 @@ ls output/
apisix-dashboard-2.4-0.x86_64.rpm
```

Packaging a Centos 7 package of APISIX's OpenResty distribution
```sh
make package type=rpm app=apisix-openresty version=1.19.3.2
tzssangglass marked this conversation as resolved.
Show resolved Hide resolved
ls output/
apisix-openresty-1.19.3.2-0.x86_64.rpm
```

## Details

- `Makefile` the entrance of the packager
Expand Down
16 changes: 16 additions & 0 deletions build-apisix-openresty-centos7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
tzssangglass marked this conversation as resolved.
Show resolved Hide resolved
set -x

yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum -y install gcc gcc-c++ patch wget git make sudo
yum -y install openresty-openssl111-devel openresty-pcre-devel openresty-zlib-devel

export openssl_prefix=/usr/local/openresty/openssl111
export zlib_prefix=/usr/local/openresty/zlib
export pcre_prefix=/usr/local/openresty/pcre

export cc_opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include"
export ld_opt="-L${zlib_prefix}/lib -L${pcre_prefix}/lib -L${openssl_prefix}/lib -Wl,-rpath,${zlib_prefix}/lib:${pcre_prefix}/lib:${openssl_prefix}/lib"

./build-apisix-openresty.sh
5 changes: 5 additions & 0 deletions build-apisix-openresty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ cd apisix-nginx-module/patch || exit 1
./patch.sh ../../openresty-${or_ver}
cd ../..

cc_opt=${cc_opt:-}
ld_opt=${ld_opt:-}

cd openresty-${or_ver} || exit 1
./configure --prefix="$OR_PREFIX" \
--with-cc-opt="$cc_opt" \
--with-ld-opt="$ld_opt" \
--add-module=../mod_dubbo \
--add-module=../ngx_multi_upstream_module \
--add-module=../apisix-nginx-module \
Expand Down
11 changes: 11 additions & 0 deletions dockerfiles/Dockerfile.apisix-openresty.rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG image_base="centos"
ARG image_tag="7"

FROM ${image_base}:${image_tag}

COPY build-apisix-openresty-centos7.sh /tmp/build-apisix-openresty-centos7.sh
COPY build-apisix-openresty.sh /tmp/build-apisix-openresty.sh

WORKDIR /tmp

RUN ["/bin/sh", "-c", "./build-apisix-openresty-centos7.sh"]
16 changes: 16 additions & 0 deletions usr/lib/systemd/system/openresty.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=APISIX's OpenResty distribution
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t
ExecStart=/usr/local/openresty/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target