Skip to content

Commit f29202f

Browse files
phssshockey
authored andcommitted
improve(docker): support multiple API URLs option (#4044)
The API_URLS environment variable can be used to run the Docker image with multiple urls. Example: docker run -p 80:8080 -e API_URLS=[{name:"First API", url:"http://firstapiurl"},{name:"Second API", url:"http://secondapiurl"}] swaggerapi/swagger-ui
1 parent c28213d commit f29202f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ MAINTAINER fehguy
55
ENV VERSION "v2.2.10"
66
ENV FOLDER "swagger-ui-2.2.10"
77
ENV API_URL "http://petstore.swagger.io/v2/swagger.json"
8+
ENV API_URLS ""
89
ENV API_KEY "**None**"
910
ENV OAUTH_CLIENT_ID "**None**"
1011
ENV OAUTH_CLIENT_SECRET "**None**"

docker-run.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ if [[ -n "$VALIDATOR_URL" ]]; then
5353
unset TMP_VU
5454
fi
5555

56-
# replace the PORT that nginx listens on if supplied
57-
if [[ -n "${PORT}" ]]; then sed -i "s|8080|${PORT}|g" /etc/nginx/nginx.conf; fi
56+
# replace `url` with `urls` option if API_URLS is set
57+
if [[ -n "$API_URLS" ]]; then
58+
sed -i "s|url: .*,|urls: $API_URLS,|g" $INDEX_FILE
59+
fi
60+
61+
# replace the PORT that nginx listens on if PORT is supplied
62+
if [[ -n "${PORT}" ]]; then
63+
sed -i "s|8080|${PORT}|g" /etc/nginx/nginx.conf
64+
fi
5865

5966
exec nginx -g 'daemon off;'

0 commit comments

Comments
 (0)