From c7730937a4b74c5433e199db9a3910580b906ba2 Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Thu, 2 Jun 2022 14:11:25 +0100 Subject: [PATCH 1/2] Skip building a container image for local previews Most of the time, you can pull the image from the internet. --- Makefile | 2 +- README.md | 3 +- .../docs/contribute/new-content/open-a-pr.md | 36 +++++++------------ 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index e0569404d6..4d99f64b12 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ container-push: container-image ## Push container image for the preview of the w container-build: module-check $(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development" -container-serve: module-check ## Boot the development server using container. Run `make container-image` before this. +container-serve: module-check ## Boot the development server using container. $(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) hugo server --buildFuture --environment development --bind 0.0.0.0 --destination /tmp/hugo --cleanDestinationDir test-examples: diff --git a/README.md b/README.md index 005452ef06..6a50a942ea 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,9 @@ git submodule update --init --recursive --depth 1 ## Running the website using a container -To build the site in a container, run the following to build the container image and run it: +To build the site in a container, run the following: ```bash -make container-image make container-serve ``` diff --git a/content/en/docs/contribute/new-content/open-a-pr.md b/content/en/docs/contribute/new-content/open-a-pr.md index 548dbac5d0..1fa6394543 100644 --- a/content/en/docs/contribute/new-content/open-a-pr.md +++ b/content/en/docs/contribute/new-content/open-a-pr.md @@ -291,34 +291,24 @@ You can either build the website's container image or run Hugo locally. Building The commands below use Docker as default container engine. Set the `CONTAINER_ENGINE` environment variable to override this behaviour. {{< /note >}} -1. Build the image locally: +1. Build the container image locally + _You only need this step if you are testing a change to the Hugo tool itself_ + ```bash + # Run this in a terminal (if required) + make container-image + ``` - ```bash - # Use docker (default) - make container-image +1. Start Hugo in a container: - ### OR ### + ```bash + # Run this in a terminal + make container-serve + ``` - # Use podman - CONTAINER_ENGINE=podman make container-image - ``` - -2. After building the `kubernetes-hugo` image locally, build and serve the site: - - ```bash - # Use docker (default) - make container-serve - - ### OR ### - - # Use podman - CONTAINER_ENGINE=podman make container-serve - ``` - -3. In a web browser, navigate to `https://localhost:1313`. Hugo watches the +1. In a web browser, navigate to `https://localhost:1313`. Hugo watches the changes and rebuilds the site as needed. -4. To stop the local Hugo instance, go back to the terminal and type `Ctrl+C`, +1. To stop the local Hugo instance, go back to the terminal and type `Ctrl+C`, or close the terminal window. {{% /tab %}} From a531bcc933fe50fbf1d91f71eedfd9f19d98a01c Mon Sep 17 00:00:00 2001 From: Tim Bannister Date: Thu, 2 Jun 2022 14:13:47 +0100 Subject: [PATCH 2/2] Explain you can use Docker alternatives for local preview --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a50a942ea..21266030af 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ git submodule update --init --recursive --depth 1 To build the site in a container, run the following: ```bash +# You can set $CONTAINER_ENGINE to the name of any Docker-like container tool make container-serve ```