New Project
Setup with Docker Compose
This compose file will setup a Kong with Database.
Dockerfile with plugins
FROM kong:2.8.1-alpine
USER root
RUN luarocks install kong-oidc && \
luarocks install kong-jwt2header && \
luarocks install kong-upstream-jwt
USER kong
compose.yaml
services:
kong-database:
image: postgres:latest
deploy:
restart_policy:
condition: any
networks:
- kong-fc
environment:
- POSTGRES_USER=kong
- POSTGRES_DB=kong
- POSTGRES_PASSWORD=kong
healthcheck:
test: ["CMD", "pg_isready", "-U", "kong"]
interval: 10s
timeout: 5s
retries: 5
##
# Start the Database
# This container will create the initial necessary tables
# for storing Kong configurations and add plugins that are not in the
# original Kong image.
##
kong-migration-bootstrap:
build: .
deploy:
restart_policy:
condition: on-failure
networks:
- kong-fc
depends-on:
- kong-database
environment:
- KONG_DATASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_USER=kong
- KONG_PG_PASSWORD=kong
command: kong migrations bootstrap && kong migrations up
kong:
build: .
networks:
- kong-fc
deploy:
restart-policy:
condition: any
depends-on:
- kong-database
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_DATABASE=kong
- KONG_PG_PASSWORD=kong
- KONG_PROXY_ACCESS=/dev/stdout
- KONG_ADMIN_ACCESS=/dev/stdout
- KONG_PROXY_ERROR=/dev/stderr
- KONG_ADMIN_ERROR=/dev/stderr
- KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
- KONG_PROXY_ADMIN_API_PORT=8001
- KONG_PROXY_ADMIN_SSL_API_PORT=8444
- KONG_PLUGINS=bundled,oidc,kong-jwt2header,kong-upstream-jwt
ports:
- "80:8000"
- "443:8443"
- "8001:8001"
- "8444:8444"
healthcheck:
test: ["CMD-SHELL", "curl -I -s -L http://127.0.0.1:8000 || exit 1"]
interval: 5s
retries: 10
restart: on-failure
##
# Admin GUI interface for Kong API Gateway
##
konga:
image: pantsel/konga
networks:
- kong-fc
deploy:
restart_policy:
condition: on-failure
depends_on:
- kong-database
environment:
NODE_ENV: development
ports:
- "1337:1337"
networks:
kong-fc:
external: false
volumes:
postgres_data:
driver: local
Last updated