forked from ttc/micro-service-api
-first commit
This commit is contained in:
70
docker/kong-gateway-api/docker-compose.yml
Normal file
70
docker/kong-gateway-api/docker-compose.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
# 🔹 สร้าง network เฉพาะของ Kong (อย่าสลับชื่อ)
|
||||
networks:
|
||||
kong-api-gateway:
|
||||
name: kong-api-gateway
|
||||
driver: bridge # ใช้ network แบบ bridge (ค่า default)
|
||||
external: true
|
||||
services:
|
||||
# 🧱 DATABASE ของ Kong
|
||||
kong-database:
|
||||
image: postgres:15
|
||||
container_name: kong-database
|
||||
environment:
|
||||
POSTGRES_USER: kong # user ที่ใช้เชื่อมต่อ
|
||||
POSTGRES_DB: kong # ชื่อ database
|
||||
POSTGRES_PASSWORD: kongpass # รหัสผ่าน
|
||||
ports:
|
||||
- "55432:5432" # ✅ เปลี่ยนพอร์ต host เป็น 55432 กันชนกับ Postgres หลัก
|
||||
volumes:
|
||||
- kong-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- kong-api-gateway # ✅ ผูก network เฉพาะ Kong
|
||||
|
||||
# 🧩 Migrations (ใช้สร้างตารางใน DB ครั้งแรกเท่านั้น)
|
||||
kong-migrations: # ✅ ต้องอยู่ระดับเดียวกับ kong-database
|
||||
image: kong:3.5
|
||||
container_name: kong-migrations
|
||||
depends_on:
|
||||
- kong-database
|
||||
environment:
|
||||
KONG_DATABASE: postgres
|
||||
KONG_PG_HOST: kong-database
|
||||
KONG_PG_USER: kong
|
||||
KONG_PG_PASSWORD: kongpass
|
||||
KONG_PG_DATABASE: kong
|
||||
networks:
|
||||
- kong-api-gateway
|
||||
|
||||
# 🚪 ตัว Kong API Gateway หลัก
|
||||
kong:
|
||||
image: kong:3.5
|
||||
container_name: kong-api-gateway # ✅ ตั้งชื่อให้ชัดเจน
|
||||
depends_on:
|
||||
- kong-database
|
||||
environment:
|
||||
KONG_DATABASE: postgres
|
||||
KONG_PG_HOST: kong-database
|
||||
KONG_PG_USER: kong # ✅ เพิ่ม USER
|
||||
KONG_PG_PASSWORD: kongpass
|
||||
KONG_PG_DATABASE: kong # ✅ เพิ่ม DATABASE
|
||||
KONG_ADMIN_LISTEN: 0.0.0.0:8001
|
||||
KONG_PROXY_LISTEN: 0.0.0.0:8000, 0.0.0.0:8443 ssl
|
||||
|
||||
KONG_ADMIN_GUI_URL: http://localhost:8002
|
||||
KONG_ADMIN_GUI_LISTEN: 0.0.0.0:8002
|
||||
|
||||
KONG_ADMIN_ACCESS_LOG: /dev/stdout
|
||||
KONG_ADMIN_ERROR_LOG: /dev/stderr
|
||||
ports:
|
||||
- "8000:8000" # proxy (public)
|
||||
- "8443:8443" # proxy https
|
||||
- "8001:8001" # admin api
|
||||
- "8002:8002" # ✅ เพิ่มพอร์ตสำหรับ Kong Manager UI
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway" # ให้ container มองเห็น host (Windows/Mac)
|
||||
networks:
|
||||
- kong-api-gateway
|
||||
|
||||
# 💾 Volume สำหรับเก็บข้อมูล Postgres
|
||||
volumes:
|
||||
kong-data:
|
||||
Reference in New Issue
Block a user