Skip to content

Commit bdb25a8

Browse files
Added Developer Portal support
1 parent 3aeed30 commit bdb25a8

File tree

7 files changed

+102
-62
lines changed

7 files changed

+102
-62
lines changed

README.md

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# NGINX-Declarative-API
22

3-
This tool provides a set of declarative REST API for NGINX Instance Manager.
3+
This project provides a set of declarative REST API for [NGINX Instance Manager](https://docs.nginx.com/nginx-management-suite/nim/).
44

55
It can be used to manage NGINX Plus configuration lifecycle and to create NGINX Plus configurations using JSON service definitions.
66

7-
GitOps integration is supported when used with NGINX Instance Manager: source of truth is checked for updates (NGINX App Protect policies, TLS certificates, keys and chains/bundles) and NGINX configurations are automatically kept in sync.
7+
GitOps integration is supported when used with NGINX Instance Manager: source of truth is checked for updates (NGINX App Protect policies, TLS certificates, keys and chains/bundles, Swagger/OpenAPI definitions) and NGINX configurations are automatically kept in sync.
88

99
Use cases include:
1010

1111
- Rapid configuration generation and templating
1212
- CI/CD integration with NGINX Instance Manager (instance groups and staged configs)
1313
- NGINX App Protect DevSecOps integration
1414
- API Gateway deployments with automated Swagger / OpenAPI schemas import
15+
- API Developer portals zero-touch deployment
1516
- GitOps integration with source of truth support for
1617
- NGINX App Protect WAF policies
1718
- TLS certificates, keys and chains/bundles
@@ -22,7 +23,7 @@ Use cases include:
2223

2324
## Requirements
2425

25-
- NGINX Instance Manager 2.10+
26+
- NGINX Instance Manager 2.14+
2627
- NGINX Plus R30 or newer
2728

2829
## Architecture
@@ -100,42 +101,26 @@ Usage details and JSON schema are available here:
100101

101102
A sample Postman collection and usage instructions can be found [here](/contrib/postman)
102103

103-
### Using docker-compose
104+
## How to run
104105

105-
This is the recommended method to run NGINX Declarative API on a Linux virtual machine. Refer to [installation instructions](https://github.com/fabriziofiorucci/NGINX-Declarative-API/tree/main/contrib/docker-compose)
106+
Docker-compose is the recommended method to run NGINX Declarative API on a Linux virtual machine. Full details are available [here](https://github.com/fabriziofiorucci/NGINX-Declarative-API/tree/main/contrib/docker-compose)
106107

107-
### As a Python application
108+
## Building Docker images
108109

109-
This repository requires Python 3.10+
110-
A running instance of [redis](https://redis.io/) is required: redis host and port can be configured in the `config.toml` file.
110+
Docker images can be built and run using:
111111

112-
Run NGINX Declarative API using:
112+
git clone https://github.com/fabriziofiorucci/NGINX-Declarative-API
113113

114-
```
115-
$ git clone https://github.com/fabriziofiorucci/NGINX-Declarative-API
116-
$ cd NGINX-Declarative-API/src
117-
$ pip install -r requirements.txt
118-
$ python3 main.py
119-
```
120-
121-
### As a Docker image
122-
123-
The docker image can be built and run using:
124-
125-
```
126-
$ git clone https://github.com/fabriziofiorucci/NGINX-Declarative-API
127-
$ cd NGINX-Declarative-API
128-
$ docker build --no-cache -t nginx-declarative-api -f ./Dockerfile .
129-
$ docker run --name nginx-declarative-api -d -p 5000:5000 nginx-declarative-api
130-
```
131-
132-
Pre-built docker images are available on Docker Hub at https://hub.docker.com/repository/docker/fiorucci/nginx-declarative-api/general and can be run using:
114+
cd NGINX-Declarative-API
115+
docker build --no-cache -t fiorucci/nginx-declarative-api -f ./Dockerfile .
116+
docker run --name nginx-declarative-api -d -p 5000:5000 fiorucci/nginx-declarative-api
133117

134-
```
135-
$ docker run --rm --name nginx-declarative-api -d -p 5000:5000 <IMAGE_NAME>
136-
```
118+
cd contrib/devportal
119+
docker build --no-cache -t fiorucci/nginx-declarative-api-devportal .
120+
docker run --name devportal -d -p 5001:5000 fiorucci/nginx-declarative-api-devportal
137121

138-
Pre-built images are configured to access the redis instance on host:port `127.0.0.1:6379`. This can be changed by mounting a custom `config.toml` file on the `nginx-declarative-api` container.
122+
Pre-built docker images are available on Docker Hub at https://hub.docker.com/repository/docker/fiorucci/nginx-declarative-api/general
123+
Configuration can be customized mounting `config.toml` as a volume `nginx-declarative-api` docker image as a volume to customize
139124

140125
## REST API documentation
141126

USAGE-v3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ is:
117117
"server_url": "https://petstore.swagger.io/v2"
118118
},
119119
"developer_portal": {
120-
"enabled": false,
120+
"enabled": true,
121121
"uri": "/petstore-devportal.html"
122122
},
123123
"rate_limit": {

contrib/docker-compose/README.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Docker compose
22

3-
NGINX Declarative API can be deployed using docker compose on a Linux virtual machine running Docker.
3+
NGINX Declarative API can be deployed using docker compose on a Linux virtual machine running docker-compose v2.20+
44

55
Usage:
66

@@ -18,13 +18,14 @@ NGINX Declarative API - https://github.com/fabriziofiorucci/NGINX-Declarative-AP
1818
1919
=== Options:
2020
21-
-h - This help
22-
-c [start|stop] - Deployment command
21+
-h - This help
22+
-c [start|stop|restart] - Deployment command
2323
2424
=== Examples:
2525
26-
Deploy NGINX DAPI: ./nginx-dapi.sh -c start
27-
Remove NGINX DAPI: ./nginx-dapi.sh -c stop
26+
Deploy NGINX DAPI : ./nginx-dapi.sh -c start
27+
Remove NGINX DAPI : ./nginx-dapi.sh -c stop
28+
Restart NGINX DAPI: ./nginx-dapi.sh -c restart
2829
```
2930

3031
## How to deploy
@@ -34,26 +35,59 @@ NGINX Declarative API - https://github.com/fabriziofiorucci/NGINX-Declarative-AP
3435
- [API v1](/USAGE-v1.md) - deprecated
3536
- [API v2](/USAGE-v2.md)
3637

37-
## Starting & stopping with docker-compose
38+
## How to run
3839

3940
Starting NGINX Declarative API:
4041

4142
```
4243
$ ./nginx-dapi.sh -c start
44+
-> Updating docker images
45+
[+] Pulling 3/3
46+
✔ nginx-dapi Pulled
47+
✔ redis Pulled
48+
✔ devportal Pulled
4349
-> Deploying NGINX Declarative API
44-
Creating network "nginx-dapi_default" with the default driver
45-
Creating redis ... done
46-
Creating nginx-dapi ... done
47-
$
50+
[+] Running 3/3
51+
✔ Container redis Running
52+
✔ Container devportal Running
53+
✔ Container nginx-dapi Started
4854
```
4955

5056
Stopping NGINX Declarative API:
5157

5258
```
5359
$ ./nginx-dapi.sh -c stop
5460
-> Undeploying NGINX Declarative API
55-
Removing redis ... done
56-
Removing nginx-dapi ... done
57-
Removing network nginx-dapi_default
58-
$
61+
[+] Running 4/4
62+
✔ Container nginx-dapi Removed
63+
✔ Container devportal Removed
64+
✔ Container redis Removed
65+
✔ Network nginx-dapi_default Removed
5966
```
67+
68+
Restarting NGINX Declarative API:
69+
70+
```
71+
$ ./nginx-dapi.sh -c restart
72+
[+] Running 4/4
73+
✔ Container devportal Removed
74+
✔ Container nginx-dapi Removed
75+
✔ Container redis Removed
76+
✔ Network nginx-dapi_default Removed
77+
-> Updating docker images
78+
[+] Pulling 3/3
79+
✔ nginx-dapi Pulled
80+
✔ redis Pulled
81+
✔ devportal Pulled
82+
-> Deploying NGINX Declarative API
83+
[+] Running 4/4
84+
✔ Network nginx-dapi_default Created-> Undeploying NGINX Declarative API
85+
[+] Running 4/4
86+
✔ Container nginx-dapi Removed
87+
✔ Container devportal Removed
88+
✔ Container redis Removed
89+
✔ Network nginx-dapi_default Removed
90+
✔ Container devportal Started
91+
✔ Container redis Started
92+
✔ Container nginx-dapi Started
93+
```

contrib/docker-compose/docker-compose.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.2"
1+
version: "3.9"
22

33
volumes:
44
redis_data:
@@ -11,6 +11,8 @@ services:
1111
restart: always
1212
ports:
1313
- "6379:6379"
14+
networks:
15+
- dapi-network
1416
volumes:
1517
- redis_data:/data:rw
1618

@@ -21,6 +23,8 @@ services:
2123
restart: always
2224
ports:
2325
- "5001:5000"
26+
networks:
27+
- dapi-network
2428

2529
nginx-dapi:
2630
image: fiorucci/nginx-declarative-api:latest
@@ -31,3 +35,8 @@ services:
3135
- redis
3236
ports:
3337
- "5000:5000"
38+
networks:
39+
- dapi-network
40+
41+
networks:
42+
dapi-network:

contrib/docker-compose/nginx-dapi.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ This script is used to deploy/undeploy NGINX Declarative API using docker-compos
99
=== Usage:\n\n
1010
$0 [options]\n\n
1111
=== Options:\n\n
12-
-h\t\t\t- This help\n
13-
-c [start|stop]\t- Deployment command\n\n
12+
-h\t\t\t\t- This help\n
13+
-c [start|stop|restart]\t- Deployment command\n\n
1414
=== Examples:\n\n
15-
Deploy NGINX DAPI:\t$0 -c start\n
16-
Remove NGINX DAPI:\t$0 -c stop\n
15+
Deploy NGINX DAPI :\t$0 -c start\n
16+
Remove NGINX DAPI :\t$0 -c stop\n
17+
Restart NGINX DAPI:\t$0 -c restart\n
1718
"
1819

1920
echo -e $BANNER 2>&1
@@ -51,6 +52,14 @@ echo "-> Undeploying NGINX Declarative API"
5152
COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML down
5253
}
5354

55+
#
56+
# NGINX Declarative API restart
57+
#
58+
nginx_dapi_restart() {
59+
nginx_dapi_stop
60+
nginx_dapi_start
61+
}
62+
5463
#
5564
# Main
5665
#
@@ -70,7 +79,7 @@ do
7079
esac
7180
done
7281

73-
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" == +(start|stop) ]]
82+
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" == +(start|stop|restart) ]]
7483
then
7584
usage
7685
fi
@@ -82,4 +91,7 @@ case "$ACTION" in
8291
stop)
8392
nginx_dapi_stop
8493
;;
94+
restart)
95+
nginx_dapi_restart
96+
;;
8597
esac

0 commit comments

Comments
 (0)