Skip to content

Commit d4462ef

Browse files
authored
Docker compose updates (#96)
* 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
1 parent f24731d commit d4462ef

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

contrib/docker-compose/README.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ NGINX Declarative API - https://github.com/f5devcentral/NGINX-Declarative-API/
2323
2424
=== Options:
2525
26-
-h - This help
27-
-c [start|stop|build] - Deployment command
26+
-h - This help
27+
-c [start|stop|build] - Deployment command
28+
-a <port> - Custom port for NGINX Declarative API (default: 5000)
29+
-d <port> - Custom port for Developer Portal (default: 5001)
30+
-r <port> - Custom port for Redis (default: 6379)
2831
2932
=== Examples:
3033
31-
Deploy NGINX Declarative API: ./nginx-dapi.sh -c start
32-
Remove NGINX Declarative API: ./nginx-dapi.sh -c stop
33-
Build docker images: ./nginx-dapi.sh -c build
34+
Deploy NGINX Declarative API: ./nginx-dapi.sh -c start
35+
Deploy with custom Declarative API port: ./nginx-dapi.sh -c start -a 8080
36+
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
38+
Remove NGINX Declarative API: ./nginx-dapi.sh -c stop
39+
Build docker images: ./nginx-dapi.sh -c build
3440
3541
```
3642

@@ -60,6 +66,25 @@ Starting:
6066
```commandline
6167
$ ./nginx-dapi.sh -c start
6268
-> Deploying NGINX Declarative API
69+
NGINX Declarative API port: 5000
70+
Developer Portal port: 5001
71+
Redis port: 6379
72+
[+] Building 0.0s (0/0)
73+
[+] Running 4/4
74+
✔ Network nginx-dapi_dapi-network Created
75+
✔ Container redis Started
76+
✔ Container devportal Started
77+
✔ Container nginx-dapi Started
78+
```
79+
80+
Starting with custom ports (useful when default ports are in use):
81+
82+
```commandline
83+
$ ./nginx-dapi.sh -c start -a 8080 -d 8081 -r 6380
84+
-> Deploying NGINX Declarative API
85+
NGINX Declarative API port: 8080
86+
Developer Portal port: 8081
87+
Redis port: 6380
6388
[+] Building 0.0s (0/0)
6489
[+] Running 4/4
6590
✔ Network nginx-dapi_dapi-network Created

contrib/docker-compose/docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
container_name: "redis"
88
restart: always
99
ports:
10-
- "6379:6379"
10+
- "${REDIS_PORT:-6379}:6379"
1111
networks:
1212
- dapi-network
1313
volumes:
@@ -22,7 +22,7 @@ services:
2222
container_name: "devportal"
2323
restart: always
2424
ports:
25-
- "5001:5000"
25+
- "${DEVPORTAL_PORT:-5001}:5000"
2626
networks:
2727
- dapi-network
2828

@@ -37,7 +37,7 @@ services:
3737
depends_on:
3838
- redis
3939
ports:
40-
- "5000:5000"
40+
- "${DAPI_PORT:-5000}:5000"
4141
networks:
4242
- dapi-network
4343

contrib/docker-compose/nginx-dapi.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ 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|build]\t- Deployment command\n\n
12+
-h\t\t\t\t- This help\n
13+
-c [start|stop|build]\t\t- Deployment command\n
14+
-a <port>\t\t\t- Custom port for NGINX Declarative API (default: 5000)\n
15+
-d <port>\t\t\t- Custom port for Developer Portal (default: 5001)\n
16+
-r <port>\t\t\t- Custom port for Redis (default: 6379)\n\n
1417
=== Examples:\n\n
15-
Deploy NGINX Declarative API:\t$0 -c start\n
16-
Remove NGINX Declarative API:\t$0 -c stop\n
17-
Build docker images:\t\t$0 -c build\n
18+
Deploy NGINX Declarative API:\t\t\t$0 -c start\n
19+
Deploy with custom Declarative API port:\t$0 -c start -a 8080\n
20+
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
22+
Remove NGINX Declarative API:\t\t\t$0 -c stop\n
23+
Build docker images:\t\t\t\t$0 -c build\n
1824
"
1925

2026
echo -e $BANNER 2>&1
@@ -30,8 +36,14 @@ nginx_dapi_start() {
3036
USERNAME=`whoami`
3137
export USERID=`id -u $USERNAME`
3238
export USERGROUP=`id -g $USERNAME`
39+
export DAPI_PORT=${DAPI_PORT:-5000}
40+
export DEVPORTAL_PORT=${DEVPORTAL_PORT:-5001}
41+
export REDIS_PORT=${REDIS_PORT:-6379}
3342

3443
echo "-> Deploying NGINX Declarative API"
44+
echo " NGINX Declarative API port: $DAPI_PORT"
45+
echo " Developer Portal port: $DEVPORTAL_PORT"
46+
echo " Redis port: $REDIS_PORT"
3547
COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML up -d --remove-orphans
3648
}
3749

@@ -71,7 +83,7 @@ COMPOSE_HTTP_TIMEOUT=240 docker-compose -p $PROJECT_NAME -f $DOCKER_COMPOSE_YAML
7183
DOCKER_COMPOSE_YAML="docker-compose.yaml"
7284
PROJECT_NAME="nginx-dapi"
7385

74-
while getopts 'hc:' OPTION
86+
while getopts 'hc:a:d:r:' OPTION
7587
do
7688
case "$OPTION" in
7789
h)
@@ -80,10 +92,19 @@ do
8092
c)
8193
ACTION=$OPTARG
8294
;;
95+
a)
96+
DAPI_PORT=$OPTARG
97+
;;
98+
d)
99+
DEVPORTAL_PORT=$OPTARG
100+
;;
101+
r)
102+
REDIS_PORT=$OPTARG
103+
;;
83104
esac
84105
done
85106

86-
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" == +(start|stop|build) ]]
107+
if [ -z "${ACTION}" ] || [[ ! "${ACTION}" =~ ^(start|stop|build)$ ]]
87108
then
88109
usage
89110
fi

0 commit comments

Comments
 (0)