Created
April 23, 2019 23:06
-
-
Save Maniacal/de2ce706f1ef0acb1b2160fce3f359e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
declare -a array | |
declare -i length current | |
set -e | |
NGINX_ROOT=/usr/share/nginx/html | |
SPEC_ROOT=$NGINX_ROOT/specs | |
INDEX_FILE=$NGINX_ROOT/index.html | |
API_URLS="[" | |
array=($SPEC_ROOT/*.yaml) | |
length=${#array[@]} | |
current=0 | |
for filename in $SPEC_ROOT/*.yaml; do | |
current=$((current + 1)) | |
name=${filename##*/} | |
base=${name%.yaml} | |
if [[ "$current" -eq "$length" ]]; then | |
API_URLS+="{url: \"./specs/$name\", name: \"$base\"}]" | |
else | |
API_URLS+="{url: \"./specs/$name\", name: \"$base\"}, " | |
fi | |
done | |
## replace `url` with `urls` option if API_URLS is set | |
if [[ -n "$API_URLS" ]]; then | |
sed -i "s|^\(\s*\)url: .*,|\1urls: $API_URLS,|g" $INDEX_FILE | |
fi | |
exec nginx -g 'daemon off;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM swaggerapi/swagger-ui | |
RUN apk add bash && \ | |
mkdir -p /usr/share/nginx/html/specs && \ | |
chown -R nginx:nginx /usr/share/nginx/html/specs | |
COPY ./api_docs/* /usr/share/nginx/html/specs/ | |
COPY ./docker-run.sh /usr/share/nginx/ | |
RUN chmod +x /usr/share/nginx/docker-run.sh | |
CMD ["/bin/bash", "/usr/share/nginx/docker-run.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment