diff --git a/README.markdown b/README.markdown index 242fa39..9282be6 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ [Heroku Buildpack](https://devcenter.heroku.com/articles/buildpacks) for [Kong](https://getkong.org/about/) ========================= -Deploy [Kong 0.11 Community Edition](https://konghq.com/kong-community-edition/) as a Heroku app. +Deploy [Kong 0.14 Community Edition](https://konghq.com/kong-community-edition/) as a Heroku app. 🌈 This buildpack now deploys genuine Mashape Kong, [built from source on Github](bin/compile#L226); patches are no longer required for compatibility with Heroku. @@ -45,10 +45,10 @@ git push heroku master #### Plugins & other Lua source * [Kong plugins](https://getkong.org/plugins/) - * [Development guide](https://getkong.org/docs/0.11.x/plugin-development/) + * [Development guide](https://docs.konghq.com/0.14.x/plugin-development/) * `lib/kong/plugins/{NAME}` * Add each Kong plugin name to the `custom_plugins` comma-separated list in `config/kong.conf.etlua` - * See: [Plugin File Structure](https://getkong.org/docs/0.11.x/plugin-development/file-structure/) + * See: [Plugin File Structure](https://docs.konghq.com/0.14.x/plugin-development/file-structure/) * Lua rocks * specify in the app's `Rockfile` * each line is `{NAME} {VERSION}` @@ -81,13 +81,13 @@ To use env vars within your own code. #### Nginx config -Kong is an Nginx-based application. To customize the underlying Nginx configuration, commit the file `config/nginx.template` with contents based on [the docs](https://getkong.org/docs/0.11.x/configuration/#custom-nginx-configuration) or [this included sample](config/nginx.template.sample). +Kong is an Nginx-based application. To customize the underlying Nginx configuration, commit the file `config/nginx.template` with contents based on [the docs](https://docs.konghq.com/0.14.x/configuration/#custom-nginx-configuration) or [this included sample](config/nginx.template.sample). #### Testing This buildpack supports [Heroku CI](https://devcenter.heroku.com/articles/heroku-ci) to automate test runs and integrate with deployment workflow. -Tests should follow the [Kong plugin testing](https://getkong.org/docs/0.11.x/plugin-development/tests/) guide. +Tests should follow the [Kong plugin testing](https://docs.konghq.com/0.14.x/plugin-development/tests/) guide. App requirements: diff --git a/bin/app/heroku-buildpack-kong-busted b/bin/app/heroku-buildpack-kong-busted index a6d9bb7..85dca42 100755 --- a/bin/app/heroku-buildpack-kong-busted +++ b/bin/app/heroku-buildpack-kong-busted @@ -1,13 +1,70 @@ #!/usr/bin/env resty +local DEFAULT_RESTY_FLAGS="-c 4096" + +do + local lines = getmetatable(io.output()).lines + + getmetatable(io.output()).lines = function(self, ...) + local iter = lines(self, ...) + + return function() + local ok, ret = pcall(iter) + if ok then + return ret + end + end + end +end + +if not os.getenv("KONG_BUSTED_RESPAWNED") then + -- initial run, so go update the environment + local script = {} + for line in io.popen("set"):lines() do + local ktvar, val = line:match("^KONG_TEST_([^=]*)=(.*)") + if ktvar then + -- reinserted KONG_TEST_xxx as KONG_xxx; append + table.insert(script, "export KONG_" .. ktvar .. "=" ..val) + end + + local var = line:match("^(KONG_[^=]*)") + if var then + -- remove existing KONG_xxx and KONG_TEST_xxx variables; prepend + table.insert(script, 1, "unset " .. var) + end + end + -- add cli recursion detection + table.insert(script, "export KONG_BUSTED_RESPAWNED=1") + + -- rebuild the invoked commandline, while inserting extra resty-flags + local resty_flags = DEFAULT_RESTY_FLAGS + local cmd = { "exec" } + for i = -1, #arg do + if arg[i]:sub(1, 12) == "RESTY_FLAGS=" then + resty_flags = arg[i]:sub(13, -1) + + else + table.insert(cmd, "'" .. arg[i] .. "'") + end + end + + if resty_flags then + table.insert(cmd, 3, resty_flags) + end + + table.insert(script, table.concat(cmd, " ")) + + -- recurse cli command, with proper variables (un)set for clean testing + local _, _, rc = os.execute(table.concat(script, "; ")) + os.exit(rc) +end + require "luarocks.loader" -require("kong.core.globalpatches")({ +require("kong.globalpatches")({ cli = true, rbusted = true }) -package.path = "?/init.lua;"..package.path - -- Busted command-line runner require 'busted.runner'({ standalone = false }) diff --git a/bin/compile b/bin/compile index 1918e5f..6dd7fb5 100755 --- a/bin/compile +++ b/bin/compile @@ -38,7 +38,7 @@ if [ -f "${ENV_DIR}/KONG_GIT_COMMITISH" ] then KONG_GIT_COMMITISH=`cat ${ENV_DIR}/KONG_GIT_COMMITISH` else - KONG_GIT_COMMITISH="0.11.1" + KONG_GIT_COMMITISH="0.14.1" fi KONG_SOURCE_DIR="${BP_CACHE_DIR}/kong-source" @@ -47,9 +47,9 @@ KONG_SOURCE_DIR="${BP_CACHE_DIR}/kong-source" # Set dependency versions. # These correspond to the archives in `vendor/`. # If upgrading any those archives, then update the corresponding version here. -LUAROCKS_VERSION=2.4.2 -OPENSSL_VERSION=1.0.2l -OPENRESTY_VERSION=1.11.2.4 +LUAROCKS_VERSION=2.4.4 +OPENSSL_VERSION=1.0.2o +OPENRESTY_VERSION=1.13.6.2 function error() { echo " ! $*" >&2 @@ -173,15 +173,16 @@ then cd ${VENDOR_CACHE_DIR} topic "Building OpenSSL" - tar -xf openssl-${OPENSSL_VERSION}.tar.gz - cd openssl-${OPENSSL_VERSION} + openssl_name="openssl-${OPENSSL_VERSION}" + mkdir -p "${openssl_name}" + tar -xz -f "${openssl_name}.tar.gz" -C "${openssl_name}" --strip-components=1 + cd "${openssl_name}" ./config --prefix=$APP_PREFIX -fPIC make make install cd .. topic "Building OpenResty" - tar -xf openssl-${OPENSSL_VERSION}.tar.gz tar -xf openresty-${OPENRESTY_VERSION}.tar.gz cd openresty-${OPENRESTY_VERSION} ./configure --prefix=$APP_PREFIX --with-pcre-jit --with-ipv6 --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_v2_module --with-openssl=${VENDOR_CACHE_DIR}/openssl-${OPENSSL_VERSION} diff --git a/bin/test b/bin/test index 5cf296f..20c7661 100755 --- a/bin/test +++ b/bin/test @@ -12,8 +12,13 @@ set -o pipefail BUILD_DIR="${1:-}" ENV_DIR="${2:-}" -# Override normal non-SSL Postgres test config. -export KONG_PG_SSL="${KONG_PG_SSL:-on}" +# Reexports to test config +export KONG_TEST_PG_USER="${KONG_PG_USER}" +export KONG_TEST_PG_PASSWORD="${KONG_PG_PASSWORD}" +export KONG_TEST_PG_HOST="${KONG_PG_HOST}" +export KONG_TEST_PG_PORT="${KONG_PG_PORT}" +export KONG_TEST_PG_DATABASE="${KONG_PG_DATABASE}" +export KONG_TEST_PG_SSL="${KONG_PG_SSL:-on}" # Use test config in the app. export KONG_CONF="spec/kong_tests.conf" diff --git a/vendor/luarocks-2.4.2.tar.gz b/vendor/luarocks-2.4.2.tar.gz deleted file mode 100644 index 8759586..0000000 Binary files a/vendor/luarocks-2.4.2.tar.gz and /dev/null differ diff --git a/vendor/luarocks-2.4.4.tar.gz b/vendor/luarocks-2.4.4.tar.gz new file mode 100644 index 0000000..b7ded01 Binary files /dev/null and b/vendor/luarocks-2.4.4.tar.gz differ diff --git a/vendor/openresty-1.11.2.4.tar.gz b/vendor/openresty-1.11.2.4.tar.gz deleted file mode 100644 index c84597b..0000000 Binary files a/vendor/openresty-1.11.2.4.tar.gz and /dev/null differ diff --git a/vendor/openresty-1.13.6.2.tar.gz b/vendor/openresty-1.13.6.2.tar.gz new file mode 100644 index 0000000..c1504fb Binary files /dev/null and b/vendor/openresty-1.13.6.2.tar.gz differ diff --git a/vendor/openssl-1.0.2l.tar.gz b/vendor/openssl-1.0.2l.tar.gz deleted file mode 100644 index 72be295..0000000 Binary files a/vendor/openssl-1.0.2l.tar.gz and /dev/null differ diff --git a/vendor/openssl-1.0.2o.tar.gz b/vendor/openssl-1.0.2o.tar.gz new file mode 100644 index 0000000..bb1ff97 Binary files /dev/null and b/vendor/openssl-1.0.2o.tar.gz differ