Giter Club home page Giter Club logo

kong-development-docker's Introduction

Docker for Kong Local Development

An unofficial Kong local development with Docker. This image can be used for Kong core or Kong plugin development. See more about kong: https://github.com/Kong/kong

This project only works with Kong version > 1.1. If you are developing legacy Kong (e.g. 0.13.x, 0.10.x), please consider to use MrSaints's Docker.

Quick Start

This repository does not contain Kong source code. You will need to clone the source code of Kong. Follow the following steps to prepare the development environment.

$ cd kong-deveopment-docker 

# get Kong source code
$ git clone https://github.com/Kong/kong

$ docker-compose up -d kong-postgres
# wait for 3 minutes
$ docker-compose up -d kong-postgres-migration
# wait for 1 minute
$ docker-compose up -d kong
# wait for 1 minute
$ docker exec kong-dev make dev

Wait util kong-dev is running. You can do a docker ps to check the status of containers

$ docker ps
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS                   PORTS                                                                NAMES
470a3ed3c2ab        kong-development-docker_kong        "/docker-entrypoint.…"   33 seconds ago      Up 32 seconds            0.0.0.0:8000-8001->8000-8001/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   kong-dev
b96486f9db40        postgres:11.2                       "docker-entrypoint.s…"   4 minutes ago       Up 4 minutes (healthy)   5432/tcp

After running the command, Kong will be listening to

The default log level is debug. Logs can be found by running docker logs -f kong-dev.

Every time after modifying Kong source code, you will need to run make dev in Kong container so the updates will be reflected.

$ docker exec kong-dev make dev
$ docker exec kong-dev kong reload

Custom plugin development

The source of cusotom plugins is in directory /custom_plugin. You will need to update the envrionment variable KONG_PLPUGINS in docker-composes.yaml

# service kong-dev
- KONG_PLUGINS=bundled,demo-plugin,<your-custom-plugin>

# service kong-test
- KONG_TEST_PLUGINS=bundled,demo-plugin,<your-custom-pugin>

Update kong service

$ docker-compose up -d kong

To prepare the testing environment, 'kong-test' should be created before executing any Kong test case.

$ docker exec -it kong-postgres psql -U kong -c 'CREATE DATABASE "kong_tests" OWNER kong;'
CREATE DATABASE

Modify the kong-postgres-migration service in docker-compose.yaml file to bootstrap the testing database.

### Update docker-compose.yaml
#      - KONG_PG_DATABASE=kong      <- comment this
      - KONG_PG_DATABASE=kong_tests  <- uncomment this
########################## 
$ docker-compose up kong-postgres-migration

Finally, bring up kong-test service, a docker service with Kong testing environment configurations.

$ docker-compose up -d kong-test

Testing

Execute /kong/bin/busted to run all test cases.

$ docker exec kong-test bin/busted
# or docker exec kong-test bin/busted -o gtest

Test only the custom plugins

$ docker exec kong-test bin/busted spec/04-custom-plugins
# or docker exec kong-test bin/busted spec/04-custom-plugins -o gtest

Connect to Kong database

$ docker exec -it kong-postgres cqlsh kong-postgres

kong-development-docker's People

Contributors

rune-chan avatar

Stargazers

 avatar  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.