Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions contrib/docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ NGINX Declarative API - https://github.com/f5devcentral/NGINX-Declarative-API/

=== Options:

-h - This help
-c [start|stop|build] - Deployment command
-h - This help
-c [start|stop|build] - Deployment command
-a <port> - Custom port for NGINX Declarative API (default: 5000)
-d <port> - Custom port for Developer Portal (default: 5001)
-r <port> - Custom port for Redis (default: 6379)

=== Examples:

Deploy NGINX Declarative API: ./nginx-dapi.sh -c start
Remove NGINX Declarative API: ./nginx-dapi.sh -c stop
Build docker images: ./nginx-dapi.sh -c build
Deploy NGINX Declarative API: ./nginx-dapi.sh -c start
Deploy with custom Declarative API port: ./nginx-dapi.sh -c start -a 8080
Deploy with custom DevPortal port: ./nginx-dapi.sh -c start -d 8081
Deploy with all custom ports: ./nginx-dapi.sh -c start -a 8080 -d 8081 -r 6380
Remove NGINX Declarative API: ./nginx-dapi.sh -c stop
Build docker images: ./nginx-dapi.sh -c build

```

Expand Down Expand Up @@ -60,6 +66,25 @@ Starting:
```commandline
$ ./nginx-dapi.sh -c start
-> Deploying NGINX Declarative API
NGINX Declarative API port: 5000
Developer Portal port: 5001
Redis port: 6379
[+] Building 0.0s (0/0)
[+] Running 4/4
✔ Network nginx-dapi_dapi-network Created
✔ Container redis Started
✔ Container devportal Started
✔ Container nginx-dapi Started
```

Starting with custom ports (useful when default ports are in use):

```commandline
$ ./nginx-dapi.sh -c start -a 8080 -d 8081 -r 6380
-> Deploying NGINX Declarative API
NGINX Declarative API port: 8080
Developer Portal port: 8081
Redis port: 6380
[+] Building 0.0s (0/0)
[+] Running 4/4
✔ Network nginx-dapi_dapi-network Created
Expand Down
6 changes: 3 additions & 3 deletions contrib/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
container_name: "redis"
restart: always
ports:
- "6379:6379"
- "${REDIS_PORT:-6379}:6379"
networks:
- dapi-network
volumes:
Expand All @@ -22,7 +22,7 @@ services:
container_name: "devportal"
restart: always
ports:
- "5001:5000"
- "${DEVPORTAL_PORT:-5001}:5000"
networks:
- dapi-network

Expand All @@ -37,7 +37,7 @@ services:
depends_on:
- redis
ports:
- "5000:5000"
- "${DAPI_PORT:-5000}:5000"
networks:
- dapi-network

Expand Down
35 changes: 28 additions & 7 deletions contrib/docker-compose/nginx-dapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ This script is used to deploy/undeploy NGINX Declarative API using docker-compos
=== Usage:\n\n
$0 [options]\n\n
=== Options:\n\n
-h\t\t\t- This help\n
-c [start|stop|build]\t- Deployment command\n\n
-h\t\t\t\t- This help\n
-c [start|stop|build]\t\t- Deployment command\n
-a <port>\t\t\t- Custom port for NGINX Declarative API (default: 5000)\n
-d <port>\t\t\t- Custom port for Developer Portal (default: 5001)\n
-r <port>\t\t\t- Custom port for Redis (default: 6379)\n\n
=== Examples:\n\n
Deploy NGINX Declarative API:\t$0 -c start\n
Remove NGINX Declarative API:\t$0 -c stop\n
Build docker images:\t\t$0 -c build\n
Deploy NGINX Declarative API:\t\t\t$0 -c start\n
Deploy with custom Declarative API port:\t$0 -c start -a 8080\n
Deploy with custom DevPortal port:\t\t$0 -c start -d 8081\n
Deploy with all custom ports:\t\t\t$0 -c start -a 8080 -d 8081 -r 6380\n
Remove NGINX Declarative API:\t\t\t$0 -c stop\n
Build docker images:\t\t\t\t$0 -c build\n
"

echo -e $BANNER 2>&1
Expand All @@ -30,8 +36,14 @@ nginx_dapi_start() {
USERNAME=`whoami`
export USERID=`id -u $USERNAME`
export USERGROUP=`id -g $USERNAME`
export DAPI_PORT=${DAPI_PORT:-5000}
export DEVPORTAL_PORT=${DEVPORTAL_PORT:-5001}
export REDIS_PORT=${REDIS_PORT:-6379}

echo "-> Deploying NGINX Declarative API"
echo " NGINX Declarative API port: $DAPI_PORT"
echo " Developer Portal port: $DEVPORTAL_PORT"
echo " Redis port: $REDIS_PORT"
COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML up -d --remove-orphans
}

Expand Down Expand Up @@ -71,7 +83,7 @@ COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML
DOCKER_COMPOSE_YAML="docker-compose.yaml"
PROJECT_NAME="nginx-dapi"

while getopts 'hc:' OPTION
while getopts 'hc:a:d:r:' OPTION
do
case "$OPTION" in
h)
Expand All @@ -80,10 +92,19 @@ do
c)
ACTION=$OPTARG
;;
a)
DAPI_PORT=$OPTARG
;;
d)
DEVPORTAL_PORT=$OPTARG
;;
r)
REDIS_PORT=$OPTARG
;;
esac
done

if [ -z "${ACTION}" ] || [[ ! "${ACTION}" == +(start|stop|build) ]]
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" =~ ^(start|stop|build)$ ]]
then
usage
fi
Expand Down