Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Kong 0.14.1 (#18)
Browse files Browse the repository at this point in the history
* Kong 0.14.0 upgrades

* Fix OpenSSL dir name

* Update Busted test runner

* Fix for PG connection refused in Heroku CI

* Kong 0.14.1 upgrade
  • Loading branch information
mars authored Sep 10, 2018
1 parent f31f2fa commit 006e284
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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}`
Expand Down Expand Up @@ -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:

Expand Down
63 changes: 60 additions & 3 deletions bin/app/heroku-buildpack-kong-busted
Original file line number Diff line number Diff line change
@@ -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 })
15 changes: 8 additions & 7 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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}
Expand Down
9 changes: 7 additions & 2 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Binary file removed vendor/luarocks-2.4.2.tar.gz
Binary file not shown.
Binary file added vendor/luarocks-2.4.4.tar.gz
Binary file not shown.
Binary file removed vendor/openresty-1.11.2.4.tar.gz
Binary file not shown.
Binary file added vendor/openresty-1.13.6.2.tar.gz
Binary file not shown.
Binary file removed vendor/openssl-1.0.2l.tar.gz
Binary file not shown.
Binary file added vendor/openssl-1.0.2o.tar.gz
Binary file not shown.

0 comments on commit 006e284

Please sign in to comment.