Coder Social home page Coder Social logo

heroku-buildpack-kong's Introduction

Deploy Kong 0.11 Community Edition as a Heroku app.

๐ŸŒˆ This buildpack now deploys genuine Mashape Kong, built from source on Github; patches are no longer required for compatibility with Heroku.

๐Ÿ”ฌ๐Ÿ‘ฉโ€๐Ÿ’ป This software is a community proof-of-concept: MIT license

Usage

Example

Deploy the heroku-kong app to get started.

Custom

Create a new git repo and Heroku app:

mkdir my-kong-app
cd my-kong-app
git init
heroku create $APP_NAME
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-kong
heroku addons:create heroku-postgresql:hobby-dev

Create the file config/kong.conf.etlua based on the sample config file. This is a config template which generates config/kong.conf at runtime.

git add config/kong.conf.etlua
git commit -m '๐Ÿ’'
git push heroku master

๐Ÿš€ Check heroku logs and heroku open to verify Kong launches.

Plugins & other Lua source

  • Kong plugins
  • Lua rocks
    • specify in the app's Rockfile
    • each line is {NAME} {VERSION}
  • Other Lua source modules
    • lib/{NAME}.lua or
    • lib/{NAME}/init.lua

Environment variables

  • PORT exposed on the app/dyno
    • set automatically by the Heroku dyno manager
  • KONG_GIT_URL git repo URL for Kong source
    • example https://github.com/Mashape/kong.git
  • KONG_GIT_COMMITISH git branch/tag/commit for Kong source
    • example master
  • DATABASE_URL

Using Environment Variables in Plugins

To use env vars within your own code.

  1. Whitelist the variable name for use within Nginx
    • In a custom Nginx config file add env MY_VARIABLE;
    • See: Nginx config (below)
  2. Access the variable in Lua plugins
    • Use os.getenv('MY_VARIABLE') to retrieve the value.

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 or this included sample.

Testing

This buildpack supports Heroku CI to automate test runs and integrate with deployment workflow.

Tests should follow the Kong plugin testing guide.

App requirements:

  • spec/kong_tests.conf must contain the Kong configuration for running tests

See: sample Heroku Kong app which contains a complete test suite.

Background

The first time this buildpack builds an app, the build time will be significantly longer as Kong and its dependencies are compiled from source. The compiled artifacts are cached to speed up subsequent builds.

We vendor the sources for Lua, LuaRocks, & OpenResty/Nginx and compile them with a writable /app/.heroku prefix. Attempts to bootstrap Kong on Heroku using existing Lua & apt buildpacks failed due to their compile-time prefixes of /usr/local which is read-only in a dyno.

OpenSSL 1.0.2 (required by OpenResty) is also compiled from source.

Modification

This buildpack caches its compilation artifacts from the sources in vendor/. Changes to the sources in vendor/ will be detected and the cache ignored.

If you need to trigger a full rebuild without changing the source, use the Heroku Repo CLI plugin to purge the cache:

heroku repo:purge_cache

heroku-buildpack-kong's People

Contributors

mars avatar

Watchers

James Cloos avatar Loรฏc PIREZ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.