From 90e2548fa0bfd1b538a6980ab860d80903b3a504 Mon Sep 17 00:00:00 2001 From: Petr Bokoc Date: Sep 16 2019 14:27:14 +0000 Subject: Revert "Update build and preview scripts" This reverts commit cb9a463a5deed898cb0feb45c883c72b2809d4af. --- diff --git a/build.sh b/build.sh index 1e4db2d..083da18 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,35 @@ #!/bin/sh -image="docker.io/antora/antora" +image="antora/antora" cmd="--html-url-extension-style=indexify site.yml" if [ "$(uname)" == "Darwin" ]; then # Running on macOS. # Let's assume that the user has the Docker CE installed # which doesn't require a root password. - echo "" - echo "This build script is using Docker container runtime to run the build in an isolated environment." - echo "" docker run --rm -it -v $(pwd):/antora $image $cmd elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then # Running on Linux. # Check whether podman is available, else faill back to docker # which requires root. - if [ -f /usr/bin/podman ]; then + runtime="podman" + else + runtime="docker" + fi + if groups | grep -wq "docker"; then + # Check if the current user is in the "docker" group. If true, no sudo is needed. echo "" - echo "This build script is using Podman to run the build in an isolated environment." - echo "" - podman run --rm -it -v $(pwd):/antora:z $image $cmd - - elif [ -f /usr/bin/docker ]; then - echo "" - echo "This build script is using Docker to run the build in an isolated environment." + echo "This build script is using $runtime to run the build in an isolated environment." echo "" - - if groups | grep -wq "docker"; then - docker run --rm -it -v $(pwd):/antora:z $image $cmd - else - echo "" - echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password." - echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/." - echo "" - sudo docker run --rm -it -v $(pwd):/antora:z $image $cmd - fi + $runtime run --rm -it -v $(pwd):/antora:z $image $cmd else + # User isn't in the docker group; run the command with sudo. + echo "" + echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password." + echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/." echo "" - echo "Error: Container runtime haven't been found on your system. Fix it by:" - echo "$ sudo dnf install podman" - exit 1 + sudo $runtime run --rm -it -v $(pwd):/antora:z $image $cmd fi fi diff --git a/preview.sh b/preview.sh index 1e4db2d..16d02d8 100755 --- a/preview.sh +++ b/preview.sh @@ -1,46 +1,36 @@ #!/bin/sh -image="docker.io/antora/antora" -cmd="--html-url-extension-style=indexify site.yml" - if [ "$(uname)" == "Darwin" ]; then # Running on macOS. # Let's assume that the user has the Docker CE installed # which doesn't require a root password. - echo "" - echo "This build script is using Docker container runtime to run the build in an isolated environment." - echo "" - docker run --rm -it -v $(pwd):/antora $image $cmd + echo "The preview will be available at http://localhost:8080/" + docker run --rm -v $(pwd):/antora:ro -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro -p 8080:80 nginx elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then # Running on Linux. # Check whether podman is available, else faill back to docker # which requires root. - if [ -f /usr/bin/podman ]; then + runtime="podman" + else + runtime="docker" + fi + if groups | grep -wq "docker"; then + # Check if the current user is in the "docker" group. If true, no sudo is needed. echo "" - echo "This build script is using Podman to run the build in an isolated environment." + echo "This build script is using $runtime to run the build in an isolated environment." + echo "The preview will be available at http://localhost:8080/" echo "" - podman run --rm -it -v $(pwd):/antora:z $image $cmd - - elif [ -f /usr/bin/docker ]; then + $runtime run --rm -v $(pwd):/antora:ro,z -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro,z -p 8080:80 nginx + else + # User isn't in the docker group; run the command with sudo. echo "" - echo "This build script is using Docker to run the build in an isolated environment." + echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password." + echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/." echo "" - - if groups | grep -wq "docker"; then - docker run --rm -it -v $(pwd):/antora:z $image $cmd - else - echo "" - echo "This build script is using $runtime to run the build in an isolated environment. You might be asked for your password." - echo "You can avoid this by adding your user to the 'docker' group, but be aware of the security implications. See https://docs.docker.com/install/linux/linux-postinstall/." - echo "" - sudo docker run --rm -it -v $(pwd):/antora:z $image $cmd - fi - else + echo "The preview will be available at http://localhost:8080/" echo "" - echo "Error: Container runtime haven't been found on your system. Fix it by:" - echo "$ sudo dnf install podman" - exit 1 + sudo $runtime run --rm -v $(pwd):/antora:ro,z -v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro,z -p 8080:80 nginx fi fi