From 9f38207ef56c15ad171886f62f0375b00a4b1ce6 Mon Sep 17 00:00:00 2001 From: Owen W. Taylor Date: Sep 04 2018 15:02:04 +0000 Subject: preview.sh: Allow preview.sh keep running for multiple build.sh calls antora deletes and recreates public/ every time the docs are rebuilt; mounting public/ directly meant that when build.sh, the existing nginx container didn't see the new docs. Instead of mounting public/ directly into the nginx default webroot, mount the parent directory at /antora, and install a tiny nginx configuration file to point the webroot at the right place. --- diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f7093b3 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + server_name localhost; + + location / { + root /antora/public; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/preview.sh b/preview.sh index acab783..d70b6e9 100755 --- a/preview.sh +++ b/preview.sh @@ -5,7 +5,7 @@ if [ "$(uname)" == "Darwin" ]; then # Let's assume that the user has the Docker CE installed # which doesn't require a root password. echo "The preview will be available at http://localhost:8080/" - docker run --rm -v $(pwd)/public:/usr/share/nginx/html:ro -p 8080:80 nginx + docker run --rm -v $(pwd):/antora:ro -p 8080:80 nginx elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then # Running on Linux. @@ -14,5 +14,5 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then echo "" echo "This build script is using Docker to run the build in an isolated environment. You might be asked for a root password in order to start it." echo "The preview will be available at http://localhost:8080/" - sudo docker run --rm -v $(pwd)/public:/usr/share/nginx/html:ro -p 8080:80 nginx + sudo docker run --rm -v $(pwd):/antora:ro,z -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro,z -p 8080:80 nginx fi