Skip to content

Commit

Permalink
feat: add optional BASE_PATH to Docker config (#1378)
Browse files Browse the repository at this point in the history
Co-authored-by: draoncc <14227820+draoncc@users.noreply.github.com>
Co-authored-by: anastasiia-developer <anastasiia@redocly.com>
  • Loading branch information
3 people committed Apr 27, 2022
1 parent aba2d1a commit 90f71c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/docker/Dockerfile
Expand Up @@ -26,6 +26,7 @@ FROM nginx:alpine

ENV PAGE_TITLE="ReDoc"
ENV PAGE_FAVICON="favicon.png"
ENV BASE_PATH=
ENV SPEC_URL="http://petstore.swagger.io/v2/swagger.json"
ENV PORT=80
ENV REDOC_OPTIONS=
Expand Down
3 changes: 2 additions & 1 deletion config/docker/README.md
Expand Up @@ -45,9 +45,10 @@ Another issue with OpenShift is that the default exposed port `80` cannot be use

- `PAGE_TITLE` (default `"ReDoc"`) - page title
- `PAGE_FAVICON` (default `"favicon.png"`) - URL to page favicon
- `BASE_PATH` (optional) - prepend favicon & standalone bundle with this path
- `SPEC_URL` (default `"http://petstore.swagger.io/v2/swagger.json"`) - URL to spec
- `PORT` (default `80`) - nginx port
- `REDOC_OPTIONS` - [`<redoc>` tag attributes](https://github.com/Redocly/redoc#redoc-tag-attributes)
- `REDOC_OPTIONS` (optional) - [`<redoc>` tag attributes](https://github.com/Redocly/redoc#redoc-tag-attributes)

## Build

Expand Down
1 change: 1 addition & 0 deletions config/docker/docker-run.sh
Expand Up @@ -4,6 +4,7 @@ set -e

sed -i -e "s|%PAGE_TITLE%|$PAGE_TITLE|g" /usr/share/nginx/html/index.html
sed -i -e "s|%PAGE_FAVICON%|$PAGE_FAVICON|g" /usr/share/nginx/html/index.html
sed -i -e "s|%BASE_PATH%|$BASE_PATH|g" /usr/share/nginx/html/index.html
sed -i -e "s|%SPEC_URL%|$SPEC_URL|g" /usr/share/nginx/html/index.html
sed -i -e "s|%REDOC_OPTIONS%|${REDOC_OPTIONS}|g" /usr/share/nginx/html/index.html
sed -i -e "s|\(listen\s*\) [0-9]*|\1 ${PORT}|g" /etc/nginx/nginx.conf
Expand Down
4 changes: 2 additions & 2 deletions config/docker/index.tpl.html
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>%PAGE_TITLE%</title>
<link rel="icon" href="%PAGE_FAVICON%" />
<link rel="icon" href="%BASE_PATH%%PAGE_FAVICON%" />
<style>
body {
margin: 0;
Expand All @@ -23,6 +23,6 @@

<body>
<redoc spec-url="%SPEC_URL%" %REDOC_OPTIONS%></redoc>
<script src="redoc.standalone.js"></script>
<script src="%BASE_PATH%redoc.standalone.js"></script>
</body>
</html>

0 comments on commit 90f71c0

Please sign in to comment.