Skip to content

Commit a6c994f

Browse files
authored
Add UI (#98)
* update extended glob pattern to use regex pattern which is more portable * update docker compose script to be compat with osx shell and create port override options * Add web UI and update supporting files * kubernetes and testing updates
1 parent f1fce0a commit a6c994f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+17190
-66
lines changed

FEATURES.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Supported features
1+
# Supported features
22

3-
### NGINX Control plane support
3+
## NGINX Control plane support
44

55
NGINX Declarative API has been tested with the following NGINX control plane releases:
66

@@ -9,7 +9,6 @@ NGINX Declarative API has been tested with the following NGINX control plane rel
99
| NGINX Instance Manager | 2.18+ | 2.20+ | |
1010
| NGINX One Console | General availability | General availability | |
1111

12-
1312
### NGINX `http` and `stream` servers
1413

1514
| Feature | API v5.4 | API v5.5 | Notes |
@@ -32,7 +31,6 @@ NGINX Declarative API has been tested with the following NGINX control plane rel
3231
| NGINX Plus REST API access | X | X | |
3332
| NGINX App Protect WAF | X | X | NGINX Instance Manager only<li>Per-policy CRUD at `server` and `location` level</li><li>Support for dataplane-based bundle compilation</li><li>Security policies can be fetched from source of truth</li> |
3433

35-
3634
### HTTP Locations
3735

3836
Locations `.declaration.http.servers[].locations[].uri` match modifiers in `.declaration.http.servers[].locations[].urimatch` can be:
@@ -115,7 +113,7 @@ See the [Postman collection](/contrib/) for usage examples
115113
#### Examples
116114

117115
ACME issuer profiles to be defined under `.declaration.http.acme_issuers[]`
118-
For full details for all fields see https://nginx.org/en/docs/http/ngx_http_acme_module.html
116+
For full details for all fields see https://nginx.org/en/docs/http/ngx_http_acme_module.html
119117

120118
```json
121119
{
@@ -458,6 +456,7 @@ Example hooks:
458456
}
459457
]
460458
```
459+
461460
- `js_periodic` - see https://nginx.org/en/docs/http/ngx_http_js_module.html#js_periodic
462461

463462
```json
@@ -543,11 +542,11 @@ DNS resolver profiles to be defined under `.declaration.http.resolvers[]`
543542
|-----------------|----------|----------|-------|
544543
| Logging formats | X | X | |
545544

546-
547545
#### Examples
548546

549547
Access and error logging available in `.declaration.http.servers[].log` and `.declaration.http.servers[].locations[].log`
550548
See:
549+
551550
* Access log: https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
552551
* Logging to syslog: https://nginx.org/en/docs/syslog.html
553552
* Error log: https://nginx.org/en/docs/ngx_core_module.html#error_log
@@ -568,6 +567,7 @@ See:
568567

569568
Access logging formats to be defined in `.declaration.http.logformats[]`
570569
See:
570+
571571
* Access log format: https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
572572

573573
```json

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This project supports [F5 NGINX Instance Manager](https://docs.nginx.com/nginx-i
99

1010
## 📚 Overview
1111

12-
At its core, the NGINX Declarative API supports **declarative configuration management** by letting users define what the state of NGINX *should be*, rather than how to get there. It eliminates the need for procedural changes by processing user-defined JSON payloads into valid and optimized NGINX configurations.
12+
At its core, the NGINX Declarative API supports **declarative configuration management** by letting users define what the state of NGINX *should be*, rather than how to get there. It eliminates the need for procedural changes by processing user-defined JSON payloads into valid and optimized NGINX configurations.
1313

1414
This tool is ideal for managing NGINX in **modern, dynamic infrastructures** such as CI/CD environments, containerized applications (like Kubernetes), or large-scale proxy server setups.
1515

@@ -21,7 +21,6 @@ This tool is ideal for managing NGINX in **modern, dynamic infrastructures** suc
2121
-**Dynamic Updates**: Handle frequent configuration changes in highly dynamic environments.
2222
-**Seamless Scalability**: Simplifies managing NGINX setups in high-scale distributed architectures.
2323

24-
2524
GitOps integration is supported: source of truth is checked for updates (F5 WAF for NGINX policies, TLS certificates, keys and chains/bundles, Swagger/OpenAPI definitions, snippets) and NGINX configurations are automatically kept in sync.
2625

2726
### 📝 Use Cases

contrib/docker-compose/README.md

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Software prerequisites are:
99

1010
Usage:
1111

12-
```
12+
```bash
1313
$ git clone https://github.com/f5devcentral/NGINX-Declarative-API
1414
$ cd NGINX-Declarative-API/contrib/docker-compose
1515
$ ./nginx-dapi.sh
@@ -26,23 +26,25 @@ NGINX Declarative API - https://github.com/f5devcentral/NGINX-Declarative-API/
2626
-h - This help
2727
-c [start|stop|build] - Deployment command
2828
-a <port> - Custom port for NGINX Declarative API (default: 5000)
29+
-w <port> - Custom port for Web UI (default: 3000)
2930
-d <port> - Custom port for Developer Portal (default: 5001)
3031
-r <port> - Custom port for Redis (default: 6379)
3132

3233
=== Examples:
3334

3435
Deploy NGINX Declarative API: ./nginx-dapi.sh -c start
3536
Deploy with custom Declarative API port: ./nginx-dapi.sh -c start -a 8080
37+
Deploy with custom Web UI port: ./nginx-dapi.sh -c start -w 8080
3638
Deploy with custom DevPortal port: ./nginx-dapi.sh -c start -d 8081
37-
Deploy with all custom ports: ./nginx-dapi.sh -c start -a 8080 -d 8081 -r 6380
39+
Deploy with all custom ports: ./nginx-dapi.sh -c start -a 8080 -w 8081 -d 8082 -r 6380
3840
Remove NGINX Declarative API: ./nginx-dapi.sh -c stop
3941
Build docker images: ./nginx-dapi.sh -c build
4042

4143
```
4244

4345
## Building docker images
4446

45-
```
47+
```bash
4648
$ ./nginx-dapi.sh -c build
4749
-> Building NGINX Declarative API Docker images
4850
[+] Building 3.6s (24/24) FINISHED
@@ -59,46 +61,110 @@ nginx-declarative-api latest 0d76c5a4338b 1 minutes ago 168M
5961
## How to run
6062

6163
1. Start NGINX Declarative API using the provided `nginx-dapi.sh` script
62-
2. Start Postman using the collection provided [here](/contrib/postman)
64+
2. Start Postman using the [Postman collection](/contrib/postman)
6365

6466
Starting:
6567

6668
```commandline
6769
$ ./nginx-dapi.sh -c start
6870
-> Deploying NGINX Declarative API
6971
NGINX Declarative API port: 5000
72+
Web UI port: 3000
7073
Developer Portal port: 5001
7174
Redis port: 6379
7275
[+] Building 0.0s (0/0)
76+
[+] Running 5/5
77+
✔ Network nginx-dapi_dapi-network Created
78+
✔ Container redis Started
79+
✔ Container devportal Started
80+
✔ Container nginx-dapi Started
81+
✔ Container nginx-dapi-webui Started
82+
```
83+
84+
Access the Web UI at <http://localhost:3000>
85+
86+
## Local Development Mode
87+
88+
For active development on the Web UI, you can run it locally with hot-reload while keeping the backend services in Docker:
89+
90+
1. **Start backend services only:**
91+
92+
```bash
93+
$ docker-compose -f docker-compose.dev.yaml up -d
7394
[+] Running 4/4
7495
✔ Network nginx-dapi_dapi-network Created
7596
✔ Container redis Started
7697
✔ Container devportal Started
77-
✔ Container nginx-dapi Started
98+
✔ Container nginx-dapi Started
99+
```
100+
101+
1. **Run Web UI locally:**
102+
103+
```bash
104+
$ cd ../../webui
105+
$ npm install # first time only
106+
$ npm run dev
107+
108+
NGINX Declarative API Web UI
109+
➜ Local: http://localhost:3000/
110+
```
111+
112+
The Vite dev server automatically proxies API requests to the containerized backend on `localhost:5000`.
113+
114+
**Using custom ports:**
115+
116+
If you started the backend with a custom DAPI port (e.g., `-a 8088`), you need to set the corresponding environment variable for the webui:
117+
118+
```bash
119+
$ ./nginx-dapi.sh -c start -m dev -a 8088
120+
121+
# Then in the webui directory:
122+
$ cd ../../webui
123+
$ VITE_DAPI_PORT=8088 npm run dev
78124
```
79125

126+
Or use the script with default ports:
127+
128+
```bash
129+
$ ./nginx-dapi.sh -c start -m dev
130+
131+
# Then in the webui directory:
132+
$ cd ../../webui
133+
$ npm run dev # Defaults to port 5000
134+
```
135+
136+
**Benefits:**
137+
138+
- ⚡ Fast hot-reload for UI changes
139+
- 🐛 Full browser debugging capabilities
140+
- 🔧 Backend services isolated in containers
141+
- 🔄 Easy to restart individual services
142+
80143
Starting with custom ports (useful when default ports are in use):
81144

82145
```commandline
83-
$ ./nginx-dapi.sh -c start -a 8080 -d 8081 -r 6380
146+
$ ./nginx-dapi.sh -c start -a 8080 -w 8081 -d 8082 -r 6380
84147
-> Deploying NGINX Declarative API
85148
NGINX Declarative API port: 8080
86-
Developer Portal port: 8081
149+
Web UI port: 8081
150+
Developer Portal port: 8082
87151
Redis port: 6380
88152
[+] Building 0.0s (0/0)
89153
[+] Running 4/4
90154
✔ Network nginx-dapi_dapi-network Created
91155
✔ Container redis Started
92156
✔ Container devportal Started
93-
✔ Container nginx-dapi Started
157+
✔ Container nginx-dapi Started
158+
✔ Container nginx-dapi-webui Started
94159
```
95160

96161
Stopping:
97162

98163
```commandline
99164
$ ./nginx-dapi.sh -c stop
100165
-> Undeploying NGINX Declarative API
101-
[+] Running 4/4
166+
[+] Running 5/5
167+
✔ Container nginx-dapi-webui Removed
102168
✔ Container nginx-dapi Removed
103169
✔ Container devportal Removed
104170
✔ Container redis Removed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
volumes:
2+
redis_data:
3+
4+
services:
5+
redis:
6+
image: redis
7+
container_name: "redis"
8+
restart: always
9+
ports:
10+
- "${REDIS_PORT:-6379}:6379"
11+
networks:
12+
- dapi-network
13+
volumes:
14+
- redis_data:/data:rw
15+
16+
devportal:
17+
image: nginx-declarative-api-devportal
18+
build:
19+
context: ../devportal/redocly
20+
dockerfile: Dockerfile
21+
user: "${USERID}:${USERGROUP}"
22+
container_name: "devportal"
23+
restart: always
24+
ports:
25+
- "${DEVPORTAL_PORT:-5001}:5000"
26+
networks:
27+
- dapi-network
28+
29+
nginx-dapi:
30+
image: nginx-declarative-api
31+
build:
32+
context: ../../
33+
dockerfile: Dockerfile
34+
user: "${USERID}:${USERGROUP}"
35+
container_name: "nginx-dapi"
36+
restart: always
37+
depends_on:
38+
- redis
39+
ports:
40+
- "${DAPI_PORT:-5000}:5000"
41+
networks:
42+
- dapi-network
43+
44+
networks:
45+
dapi-network:

contrib/docker-compose/docker-compose.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,21 @@ services:
4141
networks:
4242
- dapi-network
4343

44+
webui:
45+
image: nginx-declarative-api-webui
46+
build:
47+
context: ../../webui
48+
dockerfile: Dockerfile
49+
container_name: "nginx-dapi-webui"
50+
restart: always
51+
depends_on:
52+
- nginx-dapi
53+
environment:
54+
- DAPI_PORT=5000
55+
ports:
56+
- "${WEBUI_PORT:-3000}:80"
57+
networks:
58+
- dapi-network
59+
4460
networks:
4561
dapi-network:

contrib/docker-compose/nginx-dapi.sh

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ $0 [options]\n\n
1111
=== Options:\n\n
1212
-h\t\t\t\t- This help\n
1313
-c [start|stop|build]\t\t- Deployment command\n
14+
-m [full|dev]\t\t\t- Deployment mode: full (with webui container) or dev (backend only for local webui development) (default: full)\n
1415
-a <port>\t\t\t- Custom port for NGINX Declarative API (default: 5000)\n
16+
-w <port>\t\t\t- Custom port for Web UI (default: 3000, only for full mode)\n
1517
-d <port>\t\t\t- Custom port for Developer Portal (default: 5001)\n
1618
-r <port>\t\t\t- Custom port for Redis (default: 6379)\n\n
1719
=== Examples:\n\n
18-
Deploy NGINX Declarative API:\t\t\t$0 -c start\n
20+
Deploy NGINX Declarative API (full):\t\t$0 -c start\n
21+
Deploy in dev mode (no webui container):\t$0 -c start -m dev\n
1922
Deploy with custom Declarative API port:\t$0 -c start -a 8080\n
23+
Deploy dev mode with custom ports:\t\t$0 -c start -m dev -a 8080 -d 8081 -r 6380\n
24+
Deploy with custom Web UI port:\t\t$0 -c start -w 8080\n
2025
Deploy with custom DevPortal port:\t\t$0 -c start -d 8081\n
21-
Deploy with all custom ports:\t\t\t$0 -c start -a 8080 -d 8081 -r 6380\n
26+
Deploy with all custom ports:\t\t\t$0 -c start -a 8080 -w 8081 -d 8082 -r 6380\n
2227
Remove NGINX Declarative API:\t\t\t$0 -c stop\n
2328
Build docker images:\t\t\t\t$0 -c build\n
2429
"
@@ -37,11 +42,17 @@ USERNAME=`whoami`
3742
export USERID=`id -u $USERNAME`
3843
export USERGROUP=`id -g $USERNAME`
3944
export DAPI_PORT=${DAPI_PORT:-5000}
45+
export WEBUI_PORT=${WEBUI_PORT:-3000}
4046
export DEVPORTAL_PORT=${DEVPORTAL_PORT:-5001}
4147
export REDIS_PORT=${REDIS_PORT:-6379}
4248

43-
echo "-> Deploying NGINX Declarative API"
49+
echo "-> Deploying NGINX Declarative API ($DEPLOY_MODE mode)"
4450
echo " NGINX Declarative API port: $DAPI_PORT"
51+
if [ "$DEPLOY_MODE" = "full" ]; then
52+
echo " Web UI port: $WEBUI_PORT"
53+
else
54+
echo " Web UI: Run locally with 'cd ../../webui && npm run dev'"
55+
fi
4556
echo " Developer Portal port: $DEVPORTAL_PORT"
4657
echo " Redis port: $REDIS_PORT"
4758
COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML up -d --remove-orphans
@@ -80,10 +91,10 @@ COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML
8091
# Main
8192
#
8293

83-
DOCKER_COMPOSE_YAML="docker-compose.yaml"
8494
PROJECT_NAME="nginx-dapi"
95+
DEPLOY_MODE="full"
8596

86-
while getopts 'hc:a:d:r:' OPTION
97+
while getopts 'hc:m:a:w:d:r:' OPTION
8798
do
8899
case "$OPTION" in
89100
h)
@@ -92,9 +103,15 @@ do
92103
c)
93104
ACTION=$OPTARG
94105
;;
106+
m)
107+
DEPLOY_MODE=$OPTARG
108+
;;
95109
a)
96110
DAPI_PORT=$OPTARG
97111
;;
112+
w)
113+
WEBUI_PORT=$OPTARG
114+
;;
98115
d)
99116
DEVPORTAL_PORT=$OPTARG
100117
;;
@@ -104,11 +121,24 @@ do
104121
esac
105122
done
106123

124+
# Set docker-compose file based on mode
125+
if [ "$DEPLOY_MODE" = "dev" ]; then
126+
DOCKER_COMPOSE_YAML="docker-compose.dev.yaml"
127+
else
128+
DOCKER_COMPOSE_YAML="docker-compose.yaml"
129+
fi
130+
107131
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" =~ ^(start|stop|build)$ ]]
108132
then
109133
usage
110134
fi
111135

136+
if [[ ! "${DEPLOY_MODE}" =~ ^(full|dev)$ ]]
137+
then
138+
echo "Error: Invalid mode '${DEPLOY_MODE}'. Must be 'full' or 'dev'"
139+
usage
140+
fi
141+
112142
case "$ACTION" in
113143
start)
114144
nginx_dapi_start

0 commit comments

Comments
 (0)