Skip to content

Commit 92a2b45

Browse files
Merge pull request #1844 from renuka-fernando/dist
build(gateway): add make dist target for standalone distribution zip
2 parents eff4722 + e303b5e commit 92a2b45

5 files changed

Lines changed: 246 additions & 11 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,6 @@ gateway/gateway-runtime/target
144144
dev-policies/
145145

146146
# Copilot Prompts
147-
.github/prompts
147+
.github/prompts
148+
149+
gateway/target/

gateway/Makefile

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ help: ## Show this help message
7373
@echo ' make version-bump-next-dev - Bump to next minor dev version with SNAPSHOT'
7474
@echo ' make version-get-release - Get release version (strips SNAPSHOT suffix)'
7575
@echo ''
76+
@echo 'Distribution Targets:'
77+
@echo ' make dist - Build standalone gateway distribution zip (target/wso2apip-api-gateway-<VERSION>.zip)'
78+
@echo ' make clean-dist - Remove distribution staging dir and zip'
79+
@echo ''
7680
@echo 'Clean Targets:'
7781
@echo ' make clean - Clean all build artifacts'
7882
@echo ' make clean-db - Remove local dev SQLite database files'
@@ -215,14 +219,54 @@ version-get-release: ## Get release version (strips SNAPSHOT suffix)
215219
fi; \
216220
echo "$$VERSION"
217221

222+
# Distribution Targets
223+
DIST_VERSION := $(shell echo "$(VERSION)" | sed 's/-SNAPSHOT//')
224+
DIST_NAME := wso2apip-api-gateway-$(DIST_VERSION)
225+
DIST_DIR := target/$(DIST_NAME)
226+
DIST_ZIP := target/$(DIST_NAME).zip
227+
AI_DIST_NAME := wso2apip-ai-gateway-$(DIST_VERSION)
228+
AI_DIST_DIR := target/$(AI_DIST_NAME)
229+
AI_DIST_ZIP := target/$(AI_DIST_NAME).zip
230+
231+
.PHONY: dist
232+
dist: clean-dist ## Build standalone gateway distribution zip
233+
@echo "Building distribution $(DIST_NAME)..."
234+
@mkdir -p $(DIST_DIR)/configs $(DIST_DIR)/resources/certificates \
235+
$(DIST_DIR)/resources/listener-certs $(DIST_DIR)/resources/secure-backend
236+
@cp build.yaml build-manifest.yaml $(DIST_DIR)/
237+
@cp -R configs/. $(DIST_DIR)/configs/
238+
@cp -R observability $(DIST_DIR)/
239+
@cp gateway-controller/certificates/default-listener.crt $(DIST_DIR)/resources/certificates/
240+
@cp gateway-controller/listener-certs/default-listener.crt $(DIST_DIR)/resources/listener-certs/
241+
@cp gateway-controller/listener-certs/default-listener.key $(DIST_DIR)/resources/listener-certs/
242+
@cp -R resources/secure-backend/. $(DIST_DIR)/resources/secure-backend/
243+
@cp distribution/docker-compose.yaml $(DIST_DIR)/docker-compose.yaml
244+
@sed -i.bak \
245+
-e 's|/gateway-controller:[^[:space:]]*|/gateway-controller:$(DIST_VERSION)|g' \
246+
-e 's|/gateway-runtime:[^[:space:]]*|/gateway-runtime:$(DIST_VERSION)|g' \
247+
$(DIST_DIR)/docker-compose.yaml
248+
@rm -f $(DIST_DIR)/docker-compose.yaml.bak
249+
@sed -i.bak 's/^ version: .*/ version: $(DIST_VERSION)/' $(DIST_DIR)/build.yaml
250+
@rm -f $(DIST_DIR)/build.yaml.bak
251+
@cd target && zip -rq $(DIST_NAME).zip $(DIST_NAME)
252+
@mv $(DIST_DIR) $(AI_DIST_DIR)
253+
@cd target && zip -rq $(AI_DIST_NAME).zip $(AI_DIST_NAME)
254+
@rm -rf $(AI_DIST_DIR)
255+
@echo "✓ Built $(DIST_ZIP)"
256+
@echo "✓ Built $(AI_DIST_ZIP)"
257+
258+
.PHONY: clean-dist
259+
clean-dist: ## Remove distribution staging dir and zip
260+
@rm -rf target/wso2apip-api-gateway-* target/wso2apip-ai-gateway-*
261+
218262
# Clean Targets
219263
.PHONY: clean-db
220264
clean-db: ## Remove local dev SQLite database files
221265
rm -f gateway-controller/data/gateway.db gateway-controller/data/gateway.db-shm gateway-controller/data/gateway.db-wal
222266
@echo "Cleaned local dev database files"
223267

224268
.PHONY: clean
225-
clean: ## Clean all build artifacts
269+
clean: clean-dist ## Clean all build artifacts
226270
$(MAKE) -C gateway-controller clean
227271
$(MAKE) -C gateway-builder clean
228272
$(MAKE) -C gateway-runtime clean
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3+
#
4+
# WSO2 LLC. licenses this file to you under the Apache License,
5+
# Version 2.0 (the "License"); you may not use this file except
6+
# in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
# --------------------------------------------------------------------
18+
19+
services:
20+
gateway-controller:
21+
image: ghcr.io/wso2/api-platform/gateway-controller:1.1.0-SNAPSHOT
22+
mem_limit: 60m
23+
mem_reservation: 60m
24+
cpus: 0.025
25+
command: ["-config", "/etc/gateway-controller/config.toml"]
26+
ports:
27+
- "9090:9090" # REST API
28+
- "9094:9092" # Admin API
29+
- "9011:9091" # Metrics
30+
environment:
31+
- APIP_GW_DEVELOPMENT_MODE=true
32+
- APIP_GW_GATEWAY_REGISTRATION_TOKEN=${GATEWAY_REGISTRATION_TOKEN:-}
33+
- APIP_GW_CONTROLPLANE_HOST=${GATEWAY_CONTROLPLANE_HOST:-}
34+
volumes:
35+
- controller-data:/app/data
36+
- ./configs/config.toml:/etc/gateway-controller/config.toml:ro
37+
- ./resources/certificates:/app/certificates
38+
- ./resources/listener-certs:/app/listener-certs:ro
39+
extra_hosts:
40+
- "host.docker.internal:host-gateway"
41+
networks:
42+
- gateway-network
43+
44+
gateway-runtime:
45+
image: ghcr.io/wso2/api-platform/gateway-runtime:1.1.0-SNAPSHOT
46+
mem_limit: 180m
47+
mem_reservation: 180m
48+
cpus: 0.175
49+
command: ["--pol.config", "/etc/policy-engine/config.toml"]
50+
ports:
51+
# Router (Envoy)
52+
- "8080:8080" # HTTP ingress
53+
- "8443:8443" # HTTPS ingress
54+
- "8081:8081" # xDS-managed API listener
55+
- "9901:9901" # Envoy admin
56+
# Policy Engine
57+
- "9002:9002" # Admin API
58+
- "9003:9003" # Metrics
59+
environment:
60+
- GATEWAY_CONTROLLER_HOST=gateway-controller
61+
- MOESIF_KEY=${MOESIF_KEY:-}
62+
volumes:
63+
- ./configs/config.toml:/etc/policy-engine/config.toml:ro
64+
- ./configs/llm-pricing/model_prices.json:/etc/policy-engine/llm-pricing/model_prices.json:ro
65+
networks:
66+
- gateway-network
67+
68+
jaeger:
69+
image: jaegertracing/all-in-one:1.76.0
70+
environment:
71+
- COLLECTOR_OTLP_ENABLED=true
72+
ports:
73+
- "16686:16686" # Jaeger UI
74+
- "14268:14268" # Jaeger collector HTTP
75+
networks:
76+
- gateway-network
77+
profiles: ["tracing"]
78+
79+
otel-collector:
80+
image: otel/opentelemetry-collector:0.112.0
81+
command: ["--config=/etc/otel-collector-config.yaml"]
82+
volumes:
83+
- ./observability/otel-collector/config.yaml:/etc/otel-collector-config.yaml
84+
ports:
85+
- "4317:4317" # OTLP gRPC receiver
86+
- "4318:4318" # OTLP HTTP receiver
87+
networks:
88+
- gateway-network
89+
depends_on:
90+
- jaeger
91+
profiles: ["tracing"]
92+
93+
opensearch:
94+
image: opensearchproject/opensearch:3.4.0
95+
environment:
96+
- cluster.name=opensearch-cluster
97+
- node.name=opensearch-node1
98+
- discovery.type=single-node
99+
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
100+
- DISABLE_SECURITY_PLUGIN=true
101+
- DISABLE_INSTALL_DEMO_CONFIG=true
102+
ports:
103+
- "9200:9200"
104+
- "9600:9600"
105+
volumes:
106+
- opensearch-data:/usr/share/opensearch/data
107+
networks:
108+
- gateway-network
109+
profiles: ["logging"]
110+
111+
opensearch-dashboards:
112+
image: opensearchproject/opensearch-dashboards:3.4.0
113+
environment:
114+
- OPENSEARCH_HOSTS=["http://opensearch:9200"]
115+
- DISABLE_SECURITY_DASHBOARDS_PLUGIN=true
116+
ports:
117+
- "5601:5601"
118+
networks:
119+
- gateway-network
120+
depends_on:
121+
- opensearch
122+
profiles: ["logging"]
123+
124+
fluent-bit:
125+
image: fluent/fluent-bit:4.2.1
126+
volumes:
127+
- /var/lib/docker/containers:/var/lib/docker/containers:ro
128+
- ./observability/fluent-bit/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
129+
- ./observability/fluent-bit/parsers.conf:/fluent-bit/etc/parsers.conf
130+
- ./observability/fluent-bit/add_component.lua:/fluent-bit/scripts/add_component.lua
131+
command: /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf
132+
networks:
133+
- gateway-network
134+
depends_on:
135+
- opensearch
136+
profiles: ["logging"]
137+
138+
prometheus:
139+
image: prom/prometheus:v3.3.1
140+
volumes:
141+
- ./observability/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
142+
- prometheus-data:/prometheus
143+
command:
144+
- '--config.file=/etc/prometheus/prometheus.yml'
145+
- '--storage.tsdb.path=/prometheus'
146+
- '--web.enable-lifecycle'
147+
ports:
148+
- "9092:9090" # Prometheus UI (9092 to avoid conflict with gateway-controller)
149+
networks:
150+
- gateway-network
151+
profiles: ["metrics"]
152+
153+
grafana:
154+
image: "grafana/grafana:latest"
155+
environment:
156+
- GF_SECURITY_ADMIN_PASSWORD=admin
157+
- GF_USERS_ALLOW_SIGN_UP=false
158+
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/infrastructure-overview.json
159+
volumes:
160+
- grafana-data:/var/lib/grafana
161+
- ./observability/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
162+
- ./observability/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
163+
- ./observability/grafana/dashboards:/etc/grafana/dashboards:ro
164+
ports:
165+
- "3000:3000" # Grafana UI
166+
networks:
167+
- gateway-network
168+
depends_on:
169+
- prometheus
170+
profiles: ["metrics"]
171+
172+
volumes:
173+
controller-data:
174+
driver: local
175+
opensearch-data:
176+
driver: local
177+
prometheus-data:
178+
driver: local
179+
grafana-data:
180+
driver: local
181+
182+
networks:
183+
gateway-network:
184+
driver: bridge

gateway/docker-compose.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# --------------------------------------------------------------------
1818

1919
# NOTE: gateway-controller and gateway-runtime are duplicated in docker-compose.debug.yaml — keep in sync.
20+
# NOTE: distribution/docker-compose.yaml ships the standalone variant (assembled by `make dist`) — keep
21+
# gateway-controller/gateway-runtime services in sync there too. Documented differences that should
22+
# diverge: cert mount paths under ./resources/, no sample-backend service, empty default for
23+
# APIP_GW_CONTROLPLANE_HOST.
2024

2125
services:
2226
gateway-controller:
@@ -28,14 +32,8 @@ services:
2832
ports:
2933
- "9090:9090" # REST API
3034
- "9094:9092" # Admin API
31-
- "18000:18000" # xDS gRPC
32-
- "18001:18001" # xDS gRPC
3335
- "9011:9091" # Metrics
3436
environment:
35-
- APIP_GW_CONTROLLER_STORAGE_TYPE=sqlite
36-
- APIP_GW_CONTROLLER_STORAGE_SQLITE_PATH=./data/gateway.db
37-
- APIP_GW_CONTROLLER_LOGGING_LEVEL=info
38-
- APIP_GW_CONTROLLER_METRICS_PORT=9091
3937
- APIP_GW_DEVELOPMENT_MODE=true
4038
- APIP_GW_GATEWAY_REGISTRATION_TOKEN=${GATEWAY_REGISTRATION_TOKEN:-}
4139
- APIP_GW_CONTROLPLANE_HOST=${GATEWAY_CONTROLPLANE_HOST:-host.docker.internal:9243}
@@ -60,16 +58,13 @@ services:
6058
- "8080:8080" # HTTP ingress
6159
- "8443:8443" # HTTPS ingress
6260
- "8081:8081" # xDS-managed API listener
63-
- "8082:8082" # WebSub Hub dynamic forward proxy
64-
- "8083:8083" # WebSub Hub internal listener
6561
- "9901:9901" # Envoy admin
6662
# Policy Engine
6763
- "9002:9002" # Admin API
6864
- "9003:9003" # Metrics
6965
environment:
7066
- GATEWAY_CONTROLLER_HOST=gateway-controller
7167
- MOESIF_KEY=${MOESIF_KEY:-}
72-
- LOG_LEVEL=info
7368
volumes:
7469
- ./configs/config.toml:/etc/policy-engine/config.toml:ro
7570
- ./configs/llm-pricing/model_prices.json:/etc/policy-engine/llm-pricing/model_prices.json:ro

scripts/update-docker-compose.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ if [ -z "$COMPONENT" ] || [ -z "$VERSION" ]; then
3333
fi
3434

3535
COMPOSE_FILE="gateway/docker-compose.yaml"
36+
DIST_COMPOSE_FILE="gateway/distribution/docker-compose.yaml"
3637
IT_COMPOSE_FILE="gateway/it/docker-compose.test.yaml"
3738
EVENT_GATEWAY_COMPOSE_FILE="event-gateway/docker-compose.yaml"
3839

@@ -49,6 +50,15 @@ if [ "$COMPONENT" = "gateway" ]; then
4950
"$COMPOSE_FILE"
5051
rm -f "$COMPOSE_FILE.bak"
5152
echo "Updated $COMPOSE_FILE with gateway version $VERSION"
53+
# Mirror the same image-tag rewrite in the distribution compose template
54+
if [ -f "$DIST_COMPOSE_FILE" ]; then
55+
sed -i.bak \
56+
-e "s|image: .*/gateway-controller:.*|image: ${DOCKER_REGISTRY}/gateway-controller:$VERSION|" \
57+
-e "s|image: .*/gateway-runtime:.*|image: ${DOCKER_REGISTRY}/gateway-runtime:$VERSION|" \
58+
"$DIST_COMPOSE_FILE"
59+
rm -f "$DIST_COMPOSE_FILE.bak"
60+
echo "Updated $DIST_COMPOSE_FILE with gateway version $VERSION"
61+
fi
5262
elif [ "$COMPONENT" = "event-gateway" ]; then
5363
# Update all event-gateway component images in event-gateway docker-compose.yaml
5464
if [ ! -f "$EVENT_GATEWAY_COMPOSE_FILE" ]; then

0 commit comments

Comments
 (0)