Skip to content

Commit

Permalink
feat(openresty-build-tools) add lua-resty-lmdb to build and tempora…
Browse files Browse the repository at this point in the history
…rily turn off the inclusion by default

Co-authored-by: Datong Sun <[email protected]>
  • Loading branch information
fffonion and dndx authored Dec 21, 2021
1 parent 1467edb commit 7ddd02f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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_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}'`
OPENRESTY_PATCHES ?= 1
DOCKER_KONG_VERSION = 'master'
Expand Down Expand Up @@ -104,6 +105,7 @@ debug:
@echo ${BUILDX_INFO}
@echo ${DEBUG}
@echo ${KONG_NGINX_MODULE}
@echo ${RESTY_LMDB}

setup-ci: setup-build

Expand Down Expand Up @@ -176,6 +178,7 @@ else
--build-arg KONG_GMP_VERSION=$(KONG_GMP_VERSION) \
--build-arg KONG_NETTLE_VERSION=$(KONG_NETTLE_VERSION) \
--build-arg KONG_NGINX_MODULE=$(KONG_NGINX_MODULE) \
--build-arg RESTY_LMDB=$(RESTY_LMDB) \
--build-arg OPENRESTY_PATCHES=$(OPENRESTY_PATCHES) \
--build-arg DEBUG=$(DEBUG) \
-t $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) . )
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.openresty
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ENV OPENRESTY_PATCHES="${OPENRESTY_PATCHES}"

COPY kong-licensing /enterprise/kong-licensing
COPY lua-kong-nginx-module /enterprise/lua-kong-nginx-module
COPY lua-resty-lmdb /enterprise/lua-resty-lmdb

ARG DEBUG=1
RUN DEBUG="${DEBUG}" /tmp/build-openresty.sh \
Expand Down
1 change: 1 addition & 0 deletions lua-resty-lmdb
Submodule lua-resty-lmdb added at 187829
5 changes: 5 additions & 0 deletions openresty-build-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ Optional arguments:
--kong-nginx-module <branch> Specify a lua-kong-nginx-module branch to use when patching and compiling.
(Defaults to "master")
--no-resty-lmdb Do not include lua-resty-lmdb while patching and compiling OpenResty.
--resty-lmdb <branch> Specify a lua-resty-lmdb branch to use when patching and compiling.
(Defaults to "master")
--luarocks <luarocks_ver> Version of LuaRocks to build, such as 3.1.2. If absent, LuaRocks
will not be built.
Expand Down
43 changes: 43 additions & 0 deletions openresty-build-tools/kong-ngx-build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PCRE_VER=
FORCE=0
OPENRESTY_PATCHES=$OPENRESTY_PATCHES
KONG_NGINX_MODULE=master
RESTY_LMDB=0 # disable by default for now
DEBUG=0
NPROC=
OS=
Expand Down Expand Up @@ -86,6 +87,14 @@ main() {
KONG_NGINX_MODULE=0
shift 1
;;
--resty-lmdb)
RESTY_LMDB=$2
shift 2
;;
--no-resty-lmdb)
RESTY_LMDB=0
shift 1
;;
-f|--force)
FORCE=1
shift 1
Expand Down Expand Up @@ -319,6 +328,25 @@ main() {
popd
popd
fi

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

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

notice "Patching the components now..."
Expand Down Expand Up @@ -525,6 +553,10 @@ main() {
fi
fi

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

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

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

succ "OpenResty $OPENRESTY_VER has been built successfully!"
Expand Down Expand Up @@ -738,6 +777,10 @@ show_usage() {
echo ""
echo " --kong-nginx-module <branch> Specify a lua-kong-nginx-module branch to use when patching and compiling."
echo " (Defaults to \"master\")"
echo " --no-resty-lmdb Do not include lua-resty-lmdb while patching and compiling OpenResty."
echo ""
echo " --resty-lmdb <branch> Specify a lua-resty-lmdb branch to use when patching and compiling."
echo " (Defaults to \"master\")"
echo ""
echo " --luarocks <luarocks_ver> Version of LuaRocks to build, such as 3.1.2. If absent, LuaRocks"
echo " will not be built."
Expand Down

0 comments on commit 7ddd02f

Please sign in to comment.