From 8dd42653cc9d8d6a0b568f07901b0d4b4ca5d578 Mon Sep 17 00:00:00 2001 From: furyhawk Date: Sun, 7 Jun 2026 22:09:52 +0800 Subject: [PATCH] Add support for Podman by creating separate configuration files and updating Makefile --- apisix-gateway/Makefile | 12 ++++++---- apisix-gateway/README.md | 9 +++++++- apisix-gateway/conf/apisix.podman.yaml | 32 ++++++++++++++++++++++++++ apisix-gateway/conf/apisix.yaml | 2 +- apisix-gateway/docker-compose.yml | 2 -- apisix-gateway/podman-compose.yml | 10 ++++++++ 6 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 apisix-gateway/conf/apisix.podman.yaml create mode 100644 apisix-gateway/podman-compose.yml diff --git a/apisix-gateway/Makefile b/apisix-gateway/Makefile index e94cad4..b875bd9 100644 --- a/apisix-gateway/Makefile +++ b/apisix-gateway/Makefile @@ -1,4 +1,6 @@ +CONTAINER_ENGINE:=$(shell if command -v podman >/dev/null 2>&1; then echo podman; elif command -v docker >/dev/null 2>&1; then echo docker; else echo ""; fi) COMPOSE_CMD:=$(shell if command -v podman >/dev/null 2>&1; then if podman compose version >/dev/null 2>&1; then echo "podman compose"; elif command -v podman-compose >/dev/null 2>&1; then echo podman-compose; fi; elif command -v docker >/dev/null 2>&1; then echo "docker compose"; else echo ""; fi) +COMPOSE_FILE:=$(if $(filter podman,$(CONTAINER_ENGINE)),podman-compose.yml,docker-compose.yml) .DEFAULT_GOAL := help @@ -11,7 +13,9 @@ help: @echo " logs Follow APISIX logs" @echo " ps Show gateway containers" @echo "" + @echo "Detected container engine: $(if $(CONTAINER_ENGINE),$(CONTAINER_ENGINE),none)" @echo "Detected compose command: $(if $(COMPOSE_CMD),$(COMPOSE_CMD),none)" + @echo "Selected compose file: $(COMPOSE_FILE)" check-compose: @if [ -z "$(COMPOSE_CMD)" ]; then \ @@ -20,13 +24,13 @@ check-compose: fi up: check-compose - $(COMPOSE_CMD) up --build -d + $(COMPOSE_CMD) -f $(COMPOSE_FILE) up --build -d down: check-compose - $(COMPOSE_CMD) down + $(COMPOSE_CMD) -f $(COMPOSE_FILE) down logs: check-compose - $(COMPOSE_CMD) logs -f + $(COMPOSE_CMD) -f $(COMPOSE_FILE) logs -f ps: check-compose - $(COMPOSE_CMD) ps + $(COMPOSE_CMD) -f $(COMPOSE_FILE) ps diff --git a/apisix-gateway/README.md b/apisix-gateway/README.md index 217175a..2a57e9a 100644 --- a/apisix-gateway/README.md +++ b/apisix-gateway/README.md @@ -13,7 +13,12 @@ This project runs Apache APISIX as an API gateway in front of the LTA DataMall F - Docker or Podman with compose support - The backend service running on `http://host.docker.internal:8068` on macOS -If your backend runs on a different host or port, update the upstream target in [conf/apisix.yaml](conf/apisix.yaml). +Docker uses `host.docker.internal`. +Podman uses `host.containers.internal`. + +This project keeps separate compose wiring for each runtime and the gateway `Makefile` selects the right file automatically. + +If your backend runs on a different host or port, update the upstream target in [conf/apisix.yaml](conf/apisix.yaml) for Docker or [conf/apisix.podman.yaml](conf/apisix.podman.yaml) for Podman. ## Run @@ -39,6 +44,8 @@ make logs make ps ``` +`make up`, `make down`, `make logs`, and `make ps` automatically choose `docker-compose.yml` for Docker and `podman-compose.yml` for Podman. + ## Ports - `9080` - APISIX proxy listener diff --git a/apisix-gateway/conf/apisix.podman.yaml b/apisix-gateway/conf/apisix.podman.yaml new file mode 100644 index 0000000..f02bc5e --- /dev/null +++ b/apisix-gateway/conf/apisix.podman.yaml @@ -0,0 +1,32 @@ +routes: + - id: 1 + uri: /healthz + upstream_id: 1 + + - id: 2 + uri: /readyz + upstream_id: 1 + + - id: 3 + uri: /openapi.json + upstream_id: 1 + + - id: 4 + uri: /docs + upstream_id: 1 + + - id: 5 + uri: /redoc + upstream_id: 1 + + - id: 6 + uri: /api/v1/* + upstream_id: 1 + +upstreams: + - id: 1 + type: roundrobin + nodes: + "host.containers.internal:8068": 1 + +#END \ No newline at end of file diff --git a/apisix-gateway/conf/apisix.yaml b/apisix-gateway/conf/apisix.yaml index 532b96c..8ec06c5 100644 --- a/apisix-gateway/conf/apisix.yaml +++ b/apisix-gateway/conf/apisix.yaml @@ -27,6 +27,6 @@ upstreams: - id: 1 type: roundrobin nodes: - "host.containers.internal:8068": 1 + "host.docker.internal:8068": 1 #END diff --git a/apisix-gateway/docker-compose.yml b/apisix-gateway/docker-compose.yml index 19dd61d..e9d3018 100644 --- a/apisix-gateway/docker-compose.yml +++ b/apisix-gateway/docker-compose.yml @@ -8,5 +8,3 @@ services: ports: - "9080:9080" restart: unless-stopped - extra_hosts: - - "host.docker.internal:10.0.2.2" # Standard podman default gateway \ No newline at end of file diff --git a/apisix-gateway/podman-compose.yml b/apisix-gateway/podman-compose.yml new file mode 100644 index 0000000..74f96d7 --- /dev/null +++ b/apisix-gateway/podman-compose.yml @@ -0,0 +1,10 @@ +services: + apisix: + image: apache/apisix:3.11.0-debian + container_name: lta-datamall-apisix + volumes: + - ./conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro + - ./conf/apisix.podman.yaml:/usr/local/apisix/conf/apisix.yaml:ro + ports: + - "9080:9080" + restart: unless-stopped