Skip to content

Commit 8f73519

Browse files
authored
Merge pull request #3957 from mrparkers/base-url
Allow UI base url to be customizable
2 parents 213f6d7 + 3ee4f8d commit 8f73519

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ENV OAUTH_APP_NAME "**None**"
1313
ENV OAUTH_ADDITIONAL_PARAMS "**None**"
1414
ENV SWAGGER_JSON "/app/swagger.json"
1515
ENV PORT 80
16+
ENV BASE_URL ""
1617

1718
RUN apk add --update nginx
1819
RUN mkdir -p /run/nginx

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ Or you can provide your own swagger.json on your host
4949
docker run -p 80:8080 -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
5050
```
5151

52+
The base URL of the web application can be changed by specifying the `BASE_URL` environment variable:
53+
54+
```
55+
docker run -p 80:8080 -e BASE_URL=/swagger -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
56+
```
57+
58+
This will serve Swagger UI at `/swagger` instead of `/`.
59+
5260
##### Prerequisites
5361
- Node 6.x
5462
- NPM 3.x

docker-run.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ replace_or_delete_in_index () {
2121
fi
2222
}
2323

24+
if [ "${BASE_URL}" ]; then
25+
NGINX_WITH_BASE_URL="${NGINX_ROOT}${BASE_URL}"
26+
27+
mkdir -p ${NGINX_WITH_BASE_URL}
28+
mv ${NGINX_ROOT}/*.* ${NGINX_WITH_BASE_URL}/
29+
30+
INDEX_FILE=$NGINX_WITH_BASE_URL/index.html
31+
NGINX_ROOT=$NGINX_WITH_BASE_URL
32+
fi
33+
2434
replace_in_index myApiKeyXXXX123456789 $API_KEY
2535
replace_or_delete_in_index your-client-id $OAUTH_CLIENT_ID
2636
replace_or_delete_in_index your-client-secret-if-required $OAUTH_CLIENT_SECRET

0 commit comments

Comments
 (0)