From 3b2336126b46c021d68d646e67b993a085852857 Mon Sep 17 00:00:00 2001 From: Troy Curtis Jr Date: Oct 03 2022 21:43:30 +0000 Subject: Import scripts to build & preview locally and update the README. --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bbf921 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/build +/cache +/public diff --git a/README.md b/README.md index 383403a..cf703ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# Fedora Docs Template - -This repository contains a minimal source structure for a new Fedora Docs source. +# Fedora Docs for Fedora Badges ## Structure @@ -14,20 +12,14 @@ This repository contains a minimal source structure for a new Fedora Docs source `-- ROOT ......................... 5. |-- assets | `-- images ............... 6. - | `-- pizza.png |-- nav.adoc ................. 7. `-- pages .................... 8. - |-- architecture.adoc - |-- community.adoc - |-- faq.adoc - |-- index.adoc - |-- pizza-dough.adoc - `-- pizza-owen.adoc + `-- ... ``` 1. Metadata definition. -2. A script that does a local build. Uses docker. -3. A script that shows a preview of the site in a web browser by running a local web server. Uses docker. +2. A script that does a local build. Uses podman or docker. +3. A script that shows a preview of the site in a web browser by running a local web server. 4. A definition file for the build script. 5. A "root module of this documentation component". Please read below for an explanation. 6. **Images** to be used on any page. @@ -47,7 +39,7 @@ This repo includes scripts to build and preview the contents of this repository. **NOTE**: Please note that if you reference pages from other repositoreis, such links will be broken in this local preview as it only builds this repository. If you want to rebuild the whole Fedora Docs site, please see [the Fedora Docs build repository](https://pagure.io/fedora-docs/docs-fp-o/) for instructions. -Both scripts use docker, so please make sure you have it installed on your system. Please see below for instructions. +Both scripts use podman or docker, so please make sure you have one of them installed on your system. Please see below for instructions. To build and preview the site, run: @@ -57,11 +49,10 @@ $ ./build.sh && ./preview.sh The result will be available at http://localhost:8080 -### Installing docker on Fedora +### Installing podman on Fedora ``` -$ sudo dnf install docker -$ sudo systemctl start docker && sudo systemctl enable docker +$ sudo dnf install podman ``` ### Preview as a part of the whole Fedora Docs site diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cf8996a --- /dev/null +++ b/build.sh @@ -0,0 +1,46 @@ +#!/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 + +elif [ "$(expr substr "$(uname -s)" 1 5)" = "Linux" ]; then + # Running on Linux. + # Check whether podman is available, else fail back to docker + # which requires root. + + if [ -f /usr/bin/podman ]; then + 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 "" + + 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 "" + echo "Error: Container runtime haven't been found on your system. Fix it by:" + echo "$ sudo dnf install podman" + exit 1 + fi +fi diff --git a/preview.sh b/preview.sh new file mode 100755 index 0000000..4270107 --- /dev/null +++ b/preview.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +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 "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. + # Fedora Workstation has python3 installed as a default, so using that + echo "" + echo "The preview is available at http://localhost:8080" + echo "" + cd ./public + python3 -m http.server 8080 +fi diff --git a/site.yml b/site.yml new file mode 100644 index 0000000..6c0fb9d --- /dev/null +++ b/site.yml @@ -0,0 +1,21 @@ +site: + title: Fedora Badges (Local Preview) + start_page: badges::index +content: + sources: + - url: . + branches: HEAD + start_path: . +ui: + bundle: + url: https://asamalik.fedorapeople.org/ui-bundle.zip + snapshot: true + default_layout: with_menu +output: + clean: true + dir: ./public + destinations: + - provider: archive +runtime: + pull: true + cache_dir: ./cache