Working configuration: migrated to Docker, Kong gateway proxy functional, external Keycloak detected

This commit is contained in:
Mike Kell 2025-06-13 15:51:30 +00:00
parent 74a34f453a
commit 46426c1567
4 changed files with 34 additions and 18 deletions

2
.gitignore vendored
View File

@ -15,6 +15,8 @@ pip-wheel-metadata/
.venv/ .venv/
venv/ venv/
.env/ .env/
.idp_flag
# Poetry / pipenv virtual envs # Poetry / pipenv virtual envs
.poetry/ .poetry/
.pipenv/ .pipenv/

View File

@ -9,14 +9,14 @@ export $(shell sed -E 's/#.*//' .env | cut -d= -f1)
endif endif
# ───────────── rest of your Makefile below ───────────── # ───────────── rest of your Makefile below ─────────────
compose = podman-compose -f dev-compose.yaml compose = docker compose -f dev-compose.yaml
# #
# ---------------------------------------------------------- # ----------------------------------------------------------
# Helpers # Helpers
# ---------------------------------------------------------- # ----------------------------------------------------------
create-proxy-net: create-proxy-net:
@podman network exists nginx-proxy || podman network create nginx-proxy @docker network inspect nginx-proxy >/dev/null 2>&1 || docker network create nginx-proxy
# probe external Keycloak once and cache the flag # probe external Keycloak once and cache the flag
check-idp: check-idp:
@ -32,7 +32,7 @@ check-idp:
# Lifecycle targets # Lifecycle targets
# ---------------------------------------------------------- # ----------------------------------------------------------
build: ## Build FastAPI image build: ## Build FastAPI image
podman build -t cmmc-fastapi:latest -f .container-images/fastapi.Dockerfile . docker build -t cmmc-fastapi:latest -f .container-images/fastapi.Dockerfile .
up: create-proxy-net check-idp ## Start stack (auto-starts Keycloak only if needed) up: create-proxy-net check-idp ## Start stack (auto-starts Keycloak only if needed)
@if [ "`cat .idp_flag`" = "1" ]; then \ @if [ "`cat .idp_flag`" = "1" ]; then \
@ -44,10 +44,15 @@ up: create-proxy-net check-idp ## Start stack (auto-starts Keycloak only if need
down: ## Stop stack down: ## Stop stack
$(compose) down $(compose) down
rebuild: down build up
logs: ## Tail logs logs: ## Tail logs
$(compose) logs -f $(compose) logs -f
test: ## Run pytest test: ## Run pytest
PYTHONPATH=. pytest -q PYTHONPATH=. pytest -q
.PHONY: build up down logs test create-proxy-net check-idp ps:
$(compose) ps
.PHONY: build up down logs test create-proxy-net check-idp ps rebuild

View File

@ -35,9 +35,9 @@ services:
KEYCLOAK_URL: "${KEYCLOAK_URL:-http://keycloak:8080}" KEYCLOAK_URL: "${KEYCLOAK_URL:-http://keycloak:8080}"
KEYCLOAK_REALM: "cmmc-platform-dev" KEYCLOAK_REALM: "cmmc-platform-dev"
KEYCLOAK_CLIENT_ID: "frontend" KEYCLOAK_CLIENT_ID: "frontend"
ports: # ports:
# keep reachable only from localhost, not LAN # # keep reachable only from localhost, not LAN
- "127.0.0.1:8008:8000" # - "127.0.0.1:8008:8000"
networks: [internal] networks: [internal]
# ────────────────────────────── # ──────────────────────────────

View File

@ -1,23 +1,18 @@
_format_version: "3.0" _format_version: "3.0"
_transform: true _transform: true
#########################################################
# Upstream — FastAPI service running in podman-compose
#########################################################
services: services:
- name: fastapi-svc - name: fastapi-svc
host: fastapi # container alias on the internal network host: fastapi
port: 8000 port: 8000
protocol: http protocol: http
routes: routes:
# Public API - name: fastapi-api
- name: api-root
paths: ["/api/"] paths: ["/api/"]
strip_path: true strip_path: true
methods: ["GET", "POST", "PUT", "PATCH", "DELETE"] methods: ["GET", "POST", "PUT", "PATCH", "DELETE"]
plugins: plugins:
# Enable CORS for local testing
- name: cors - name: cors
config: config:
origins: ["*"] origins: ["*"]
@ -26,14 +21,28 @@ services:
credentials: false credentials: false
max_age: 3600 max_age: 3600
# Health probe exposed at /gateway-health - name: fastapi-health
- name: gateway-health paths: ["/gateway-health", "/healthz"]
paths: ["/gateway-health"]
strip_path: true strip_path: true
methods: ["GET"] methods: ["GET"]
- name: kong-meta
url: http://localhost:8001
routes:
- name: root-status
paths: ["/"]
strip_path: true
methods: ["GET"]
plugins:
- name: request-termination
config:
status_code: 200
content_type: application/json
body: '{"status":"Kong Gateway OK"}'
plugins: plugins:
# Global rate-limit (optional; remove if you dont need it yet)
- name: rate-limiting - name: rate-limiting
config: config:
second: 25 second: 25