From 59ec0cdf842a762f60666bb48a59e10fe7f80552 Mon Sep 17 00:00:00 2001 From: Daniel Edgar Date: Fri, 23 Jan 2026 10:33:39 -0500 Subject: [PATCH 1/2] update extended glob pattern to use regex pattern which is more portable --- contrib/docker-compose/nginx-dapi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/docker-compose/nginx-dapi.sh b/contrib/docker-compose/nginx-dapi.sh index b8f5757..97449d1 100755 --- a/contrib/docker-compose/nginx-dapi.sh +++ b/contrib/docker-compose/nginx-dapi.sh @@ -83,7 +83,7 @@ do esac done -if [ -z "${ACTION}" ] || [[ ! "${ACTION}" == +(start|stop|build) ]] +if [ -z "${ACTION}" ] || [[ ! "${ACTION}" =~ ^(start|stop|build)$ ]] then usage fi From b4422a8a058829664d65700fce2d59014e452388 Mon Sep 17 00:00:00 2001 From: Daniel Edgar Date: Fri, 23 Jan 2026 10:55:47 -0500 Subject: [PATCH 2/2] update docker compose script to be compat with osx shell and create port override options --- contrib/docker-compose/README.md | 35 ++++++++++++++++++---- contrib/docker-compose/docker-compose.yaml | 6 ++-- contrib/docker-compose/nginx-dapi.sh | 33 ++++++++++++++++---- 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/contrib/docker-compose/README.md b/contrib/docker-compose/README.md index 30a33a7..08db8ee 100644 --- a/contrib/docker-compose/README.md +++ b/contrib/docker-compose/README.md @@ -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 - Custom port for NGINX Declarative API (default: 5000) + -d - Custom port for Developer Portal (default: 5001) + -r - 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 ``` @@ -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 diff --git a/contrib/docker-compose/docker-compose.yaml b/contrib/docker-compose/docker-compose.yaml index 8416e2d..ad87ca9 100644 --- a/contrib/docker-compose/docker-compose.yaml +++ b/contrib/docker-compose/docker-compose.yaml @@ -7,7 +7,7 @@ services: container_name: "redis" restart: always ports: - - "6379:6379" + - "${REDIS_PORT:-6379}:6379" networks: - dapi-network volumes: @@ -22,7 +22,7 @@ services: container_name: "devportal" restart: always ports: - - "5001:5000" + - "${DEVPORTAL_PORT:-5001}:5000" networks: - dapi-network @@ -37,7 +37,7 @@ services: depends_on: - redis ports: - - "5000:5000" + - "${DAPI_PORT:-5000}:5000" networks: - dapi-network diff --git a/contrib/docker-compose/nginx-dapi.sh b/contrib/docker-compose/nginx-dapi.sh index 97449d1..a06061d 100755 --- a/contrib/docker-compose/nginx-dapi.sh +++ b/contrib/docker-compose/nginx-dapi.sh @@ -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 \t\t\t- Custom port for NGINX Declarative API (default: 5000)\n +-d \t\t\t- Custom port for Developer Portal (default: 5001)\n +-r \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 @@ -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 } @@ -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) @@ -80,6 +92,15 @@ do c) ACTION=$OPTARG ;; + a) + DAPI_PORT=$OPTARG + ;; + d) + DEVPORTAL_PORT=$OPTARG + ;; + r) + REDIS_PORT=$OPTARG + ;; esac done