Skip to content

Commit 20a721f

Browse files
authored
feat: add build-apisix-openresty-rpm (#40)
1 parent 28965e8 commit 20a721f

File tree

6 files changed

+88
-2
lines changed

6 files changed

+88
-2
lines changed

Makefile

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,34 @@ package-dashboard-rpm:
7676

7777
rm -rf ${PWD}/build
7878

79-
ifeq ($(filter $(app),apisix dashboard),)
79+
### build apisix-openresty:
80+
.PHONY: build-apisix-openresty-rpm
81+
build-apisix-openresty-rpm:
82+
mkdir -p ${PWD}/build/rpm
83+
docker build -t apache/apisix-openresty:$(version) -f ./dockerfiles/Dockerfile.apisix-openresty.rpm .
84+
docker run -d --name dockerInstance --net="host" apache/apisix-openresty:$(version)
85+
docker cp dockerInstance:/usr/local/openresty/ ${PWD}/build/rpm
86+
docker system prune -a -f
87+
88+
### build rpm for apisix-openresty:
89+
.PHONY: package-apisix-openresty-rpm
90+
package-apisix-openresty-rpm:
91+
fpm -f -s dir -t rpm \
92+
-n apisix-openresty \
93+
-a `uname -i` \
94+
-v $(version) \
95+
--iteration $(iteration) \
96+
--description "APISIX's OpenResty distribution." \
97+
--license "ASL 2.0" \
98+
-C ${PWD}/build/rpm \
99+
-p ${PWD}/output/ \
100+
--url 'http://apisix.apache.org/' \
101+
--conflicts openresty \
102+
--config-files usr/lib/systemd/system/openresty.service \
103+
--prefix=/usr/local
104+
rm -rf ${PWD}/build
105+
106+
ifeq ($(filter $(app),apisix dashboard apisix-openresty),)
80107
$(info the app's value have to be apisix or dashboard!)
81108

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

115+
else ifeq ($(app)_$(type),apisix-openresty_rpm)
116+
package: build-apisix-openresty-rpm
117+
package: package-apisix-openresty-rpm
118+
88119
else ifeq ($(checkout), 0)
89120
$(info you have to input a checkout value!)
90121

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
|Parameter |Required |Description |Example|
1010
|---------|---------|----|-----------|
1111
|type |True |it can be `deb` or `rpm` |type=rpm|
12-
|app |True |it can be `apisix` or `dashboard` |app=apisix|
12+
|app |True |it can be `apisix`, `dashboard` or `apisix-openresty`|app=apisix|
1313
|checkout |True |the code branch or tag of the app which you want to package|checkout=2.1 or checkout=v2.1|
1414
|version |True |the version of the package|version=10.10|
1515
|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|
@@ -30,6 +30,13 @@ ls output/
3030
apisix-dashboard-2.4-0.x86_64.rpm
3131
```
3232

33+
Packaging a Centos 7 package of APISIX's OpenResty distribution
34+
```sh
35+
make package type=rpm app=apisix-openresty version=1.19.3.2
36+
ls output/
37+
apisix-openresty-1.19.3.2-0.x86_64.rpm
38+
```
39+
3340
## Details
3441

3542
- `Makefile` the entrance of the packager

build-apisix-openresty-centos7.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
set -x
4+
5+
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
6+
yum -y install gcc gcc-c++ patch wget git make sudo
7+
yum -y install openresty-openssl111-devel openresty-pcre-devel openresty-zlib-devel
8+
9+
export openssl_prefix=/usr/local/openresty/openssl111
10+
export zlib_prefix=/usr/local/openresty/zlib
11+
export pcre_prefix=/usr/local/openresty/pcre
12+
13+
export cc_opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include"
14+
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"
15+
16+
./build-apisix-openresty.sh

build-apisix-openresty.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ cd apisix-nginx-module/patch || exit 1
5454
./patch.sh ../../openresty-${or_ver}
5555
cd ../..
5656

57+
cc_opt=${cc_opt:-}
58+
ld_opt=${ld_opt:-}
59+
5760
cd openresty-${or_ver} || exit 1
5861
./configure --prefix="$OR_PREFIX" \
62+
--with-cc-opt="$cc_opt" \
63+
--with-ld-opt="$ld_opt" \
5964
--add-module=../mod_dubbo \
6065
--add-module=../ngx_multi_upstream_module \
6166
--add-module=../apisix-nginx-module \
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG image_base="centos"
2+
ARG image_tag="7"
3+
4+
FROM ${image_base}:${image_tag}
5+
6+
COPY build-apisix-openresty-centos7.sh /tmp/build-apisix-openresty-centos7.sh
7+
COPY build-apisix-openresty.sh /tmp/build-apisix-openresty.sh
8+
9+
WORKDIR /tmp
10+
11+
RUN ["/bin/sh", "-c", "./build-apisix-openresty-centos7.sh"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=APISIX's OpenResty distribution
3+
After=syslog.target network-online.target remote-fs.target nss-lookup.target
4+
Wants=network-online.target
5+
6+
[Service]
7+
Type=forking
8+
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
9+
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t
10+
ExecStart=/usr/local/openresty/nginx/sbin/nginx
11+
ExecReload=/bin/kill -s HUP $MAINPID
12+
ExecStop=/bin/kill -s QUIT $MAINPID
13+
PrivateTmp=true
14+
15+
[Install]
16+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)