Skip to content

Commit

Permalink
feat(openresty) bundle Kong/lua-resty-events (#460)
Browse files Browse the repository at this point in the history
This adds [Kong/lua-resty-events](https://github.com/Kong/lua-resty-events) to kong-ngx-build.
  • Loading branch information
chronolaw authored Jun 6, 2022
1 parent acfda16 commit 87a36ea
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RESTY_PCRE_VERSION ?= `grep RESTY_PCRE_VERSION $(KONG_SOURCE_LOCATION)/.requirem
KONG_GMP_VERSION ?= `grep KONG_GMP_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_NETTLE_VERSION ?= `grep KONG_NETTLE_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_NGINX_MODULE ?= `grep KONG_NGINX_MODULE $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_EVENTS ?= `grep RESTY_EVENTS $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_LMDB ?= `grep RESTY_LMDB $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
LIBYAML_VERSION ?= `grep ^LIBYAML_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_WEBSOCKET ?= `grep RESTY_WEBSOCKET $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
Expand Down Expand Up @@ -187,6 +188,7 @@ else
--build-arg KONG_NGINX_MODULE=$(KONG_NGINX_MODULE) \
--build-arg RESTY_LMDB=$(RESTY_LMDB) \
--build-arg RESTY_WEBSOCKET=$(RESTY_WEBSOCKET) \
--build-arg RESTY_EVENTS=$(RESTY_EVENTS) \
--build-arg OPENRESTY_PATCHES=$(OPENRESTY_PATCHES) \
--build-arg DEBUG=$(DEBUG) \
-t $(DOCKER_REPOSITORY):openresty-$(PACKAGE_TYPE)-$(DOCKER_OPENRESTY_SUFFIX) . )
Expand Down
5 changes: 5 additions & 0 deletions build-openresty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ then
RESTY_WEBSOCKET=0
fi

if [ -z "$RESTY_EVENTS" ]
then
RESTY_EVENTS=0
fi

LUAROCKS_PREFIX=/usr/local \
LUAROCKS_DESTDIR=/tmp/build \
Expand All @@ -64,6 +68,7 @@ EDITION=$EDITION \
--openssl $RESTY_OPENSSL_VERSION \
--resty-lmdb $RESTY_LMDB \
--resty-websocket $RESTY_WEBSOCKET \
--resty-events $RESTY_EVENTS \
--luarocks $RESTY_LUAROCKS_VERSION \
--kong-nginx-module $KONG_NGINX_MODULE \
--pcre $RESTY_PCRE_VERSION \
Expand Down
3 changes: 3 additions & 0 deletions dockerfiles/Dockerfile.openresty
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ LABEL resty_lmdb="${RESTY_LMDB}"
ARG RESTY_WEBSOCKET=0
LABEL resty_websocket="${RESTY_WEBSOCKET}"

ARG RESTY_EVENTS=0
LABEL resty_events="${RESTY_EVENTS}"

COPY openresty-build-tools /tmp/openresty-build-tools
COPY openresty-patches /tmp/openresty-patches
COPY build-openresty.sh /tmp/build-openresty.sh
Expand Down
35 changes: 35 additions & 0 deletions openresty-build-tools/kong-ngx-build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ OPENRESTY_PATCHES=$OPENRESTY_PATCHES
KONG_NGINX_MODULE=master
RESTY_LMDB=master
RESTY_WEBSOCKET=${RESTY_WEBSOCKET:-0}
RESTY_EVENTS=main
DEBUG=0
NPROC=
OS=
Expand Down Expand Up @@ -101,6 +102,10 @@ main() {
RESTY_WEBSOCKET=$2
shift 1
;;
--resty-events)
RESTY_EVENTS=$2
shift 2
;;
-f|--force)
FORCE=1
shift 1
Expand Down Expand Up @@ -390,6 +395,25 @@ main() {
popd
popd
fi

# lua-resty-events
if [ $RESTY_EVENTS != 0 ]; then
if [[ $RESTY_EVENTS == "main" ]]; then
RESTY_EVENTS="origin/main"
fi
pushd $DOWNLOAD_CACHE
if [ ! -d lua-resty-events ]; then
warn "lua-resty-events source not found, cloning..."
git clone https://github.com/Kong/lua-resty-events --recursive
fi

pushd lua-resty-events
git fetch
# Accept both tags, branches and SHAs
git reset --hard $RESTY_EVENTS || git reset --hard origin/$RESTY_EVENTS
popd
popd
fi
popd

if [ ! -z "$DOWNLOAD_ONLY" ]; then
Expand Down Expand Up @@ -622,6 +646,10 @@ main() {
OPENRESTY_OPTS+=("--add-module=$DOWNLOAD_CACHE/lua-resty-lmdb")
fi

if [ $RESTY_EVENTS != 0 ]; then
OPENRESTY_OPTS+=("--add-module=$DOWNLOAD_CACHE/lua-resty-events")
fi

if version_gte $NGINX_CORE_VER 1.11.4; then
OPENRESTY_OPTS+=('--with-stream_realip_module')
fi
Expand Down Expand Up @@ -686,6 +714,13 @@ main() {
make install LUA_LIB_DIR=$OPENRESTY_INSTALL/lualib
popd
fi

if [ $RESTY_EVENTS != 0 ]; then
pushd $DOWNLOAD_CACHE/lua-resty-events
warn "installing library files for lua-resty-events..."
make install LUA_LIB_DIR=$OPENRESTY_INSTALL/lualib
popd
fi
popd

succ "OpenResty $OPENRESTY_VER has been built successfully!"
Expand Down

0 comments on commit 87a36ea

Please sign in to comment.