Skip to content

Instantly share code, notes, and snippets.

@hhoover
Forked from deirdre-anderson/DockerComposeInstall.md
Last active July 28, 2023 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hhoover/c1a8de617080724d914623df90ee120b to your computer and use it in GitHub Desktop.
Save hhoover/c1a8de617080724d914623df90ee120b to your computer and use it in GitHub Desktop.
Sample Docker Compose for a Kong EE insallation
version: "3"
volumes:
kong_data: {}
services:
postgres:
image: postgres:13
restart: always
container_name: kong-25-postgres
networks:
- kong-ee
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres" ]
interval: 10s
timeout: 5s
retries: 10
environment:
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: kong
#Running the migrations here
kong-migrations:
image: kong/kong-gateway:2.5.0.0
container_name: kong-25-migrations
command: kong migrations bootstrap
depends_on:
postgres:
condition: service_healthy
environment:
KONG_DATABASE: postgres
KONG_PASSWORD: admin
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong}
KONG_PG_HOST: kong-25-postgres
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
KONG_PG_USER: ${KONG_PG_USER:-kong}
KONG_LICENSE_DATA: ${KONG_LICENSE_DATA}
links:
- postgres:postgres
networks:
- kong-ee
restart: on-failure
kong-ee:
image: kong/kong-gateway:2.5.0.0
user: "${KONG_USER:-root}"
container_name: kong-25
networks:
- kong-ee
depends_on:
- kong-migrations
restart: on-failure
ports:
- "8000:8000/tcp"
- "8001:8001/tcp"
- "8002:8002/tcp"
- "8003:8003/tcp"
- "8004:8004/tcp"
- "8443:8443/tcp"
- "8444:8444/tcp"
- "8445:8445/tcp"
- "8446:8446/tcp"
- "8447:8447/tcp"
- "9080:9080/tcp"
environment:
KONG_ADMIN_GUI_LISTEN: 0.0.0.0:8002, 0.0.0.0:8445 ssl
KONG_PROXY_LISTEN: 0.0.0.0:8000, 0.0.0.0:8443 ssl
KONG_ADMIN_LISTEN: 0.0.0.0:8001, 0.0.0.0:8444 ssl
KONG_LICENSE_DATA: ${KONG_LICENSE_DATA}
KONG_LOG_LEVEL: debug
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_PORTAL_API_ACCESS_LOG: /dev/stderr
KONG_PORTAL_API_ERROR_LOG: /dev/stderr
KONG_ADMIN_GUI_URL: http://host.docker.internal:8002
KONG_DATABASE: postgres
KONG_PG_HOST: kong-25-postgres
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
KONG_PG_USER: ${KONG_PG_USER:-kong}
KONG_PROXY_ACCESS_LOG: "off"
KONG_PROXY_ERROR_LOG: "/dev/stderr"
KONG_PLUGINS: bundled
KONG_PASSWORD: ${KONG_PASSWORD:-admin}
KONG_ENFORCE_RBAC: "on"
KONG_ADMIN_GUI_AUTH: basic-auth
KONG_ADMIN_GUI_SESSION_CONF: '{"cookie_name":"admin_session","cookie_samesite":"off","secret":"Y29vbGJlYW5z","cookie_secure":false,"storage":"kong"}'
KONG_PORTAL_EMAILS_FROM: noreply@konghq.com
KONG_PORTAL_EMAILS_REPLY_TO: noreply@konghq.com
KONG_PORTAL_GUI_LISTEN: 0.0.0.0:8003, 0.0.0.0:8446 ssl
KONG_PORTAL_GUI_HOST: host.docker.internal:8003
KONG_PORTAL_GUI_PROTOCOL: http
KONG_PORTAL_SESSION_CONF: '{ "cookie_name": "portal_session", "secret": "Y29vbGJlYW5z", "storage": "kong", "cookie_secure": false }'
KONG_ANONYMOUS_REPORTS: "off"
KONG_PORTAL: "on"
KONG_VITALS: "on"
networks:
kong-ee:

Local Kong EE Install with Docker-compose

Before

  • Confirm you have Docker and Docker compose installed

  • Create a environment var for you Kong License, KONG_LICENSE_DATA

  • Create a file with your json license

  • Create your environment variable KONG_LICENSE_DATA from the above file

export KONG_LICENSE_DATA=`cat /path/to/license.json`; 

Starting/Stopping Kong

  • From the parent directory of your docker-compose.yaml file

    • Start Kong with docker-compose
    docker-compose up -d
    
    • Stop Kong with docker-compose, and 'maintain' state
    docker-compose stop
    
    • Stop and Remove Kong and related containers with docker-compose
    docker-compose down
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment