From 5db4131046fd421d0be7faefc18c48873fd8d70a Mon Sep 17 00:00:00 2001 From: Michael Parker Date: Tue, 28 Nov 2017 12:01:49 -0600 Subject: [PATCH 1/2] Allow UI base url to be customizable --- Dockerfile | 1 + docker-run.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index ee177b4ebfe..fd831f04eb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ ENV OAUTH_APP_NAME "**None**" ENV OAUTH_ADDITIONAL_PARAMS "**None**" ENV SWAGGER_JSON "/app/swagger.json" ENV PORT 80 +ENV BASE_URL "" RUN apk add --update nginx RUN mkdir -p /run/nginx diff --git a/docker-run.sh b/docker-run.sh index db1216bd880..39e25f203e6 100644 --- a/docker-run.sh +++ b/docker-run.sh @@ -21,6 +21,16 @@ replace_or_delete_in_index () { fi } +if [ "${BASE_URL}" ]; then + NGINX_WITH_BASE_URL="${NGINX_ROOT}${BASE_URL}" + + mkdir -p ${NGINX_WITH_BASE_URL} + mv ${NGINX_ROOT}/*.* ${NGINX_WITH_BASE_URL}/ + + INDEX_FILE=$NGINX_WITH_BASE_URL/index.html + NGINX_ROOT=$NGINX_WITH_BASE_URL +fi + replace_in_index myApiKeyXXXX123456789 $API_KEY replace_or_delete_in_index your-client-id $OAUTH_CLIENT_ID replace_or_delete_in_index your-client-secret-if-required $OAUTH_CLIENT_SECRET From a6dd9d60e7ecbdb4a742aef5ca33776b5e61b87f Mon Sep 17 00:00:00 2001 From: Michael Parker Date: Tue, 28 Nov 2017 13:22:34 -0600 Subject: [PATCH 2/2] Add documentation to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a912fdc38b6..b1b99ae2bd7 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ Or you can provide your own swagger.json on your host docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui ``` +The base URL of the web application can be changed by specifying the `BASE_URL` environment variable: + +``` +docker run -p 80:8080 -e BASE_URL=/swagger -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui +``` + +This will serve Swagger UI at `/swagger` instead of `/`. + ##### Prerequisites - Node 6.x - NPM 3.x