Skip building a container image for local previews

Most of the time, you can pull the image from the internet.
This commit is contained in:
Tim Bannister
2022-06-02 14:11:25 +01:00
parent ea4736d2df
commit c7730937a4
3 changed files with 15 additions and 26 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ container-push: container-image ## Push container image for the preview of the w
container-build: module-check 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_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 $(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: test-examples:
+1 -2
View File
@@ -36,10 +36,9 @@ git submodule update --init --recursive --depth 1
## Running the website using a container ## 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 ```bash
make container-image
make container-serve make container-serve
``` ```
@@ -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. The commands below use Docker as default container engine. Set the `CONTAINER_ENGINE` environment variable to override this behaviour.
{{< /note >}} {{< /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 1. Start Hugo in a container:
# Use docker (default)
make container-image
### OR ### ```bash
# Run this in a terminal
make container-serve
```
# Use podman 1. In a web browser, navigate to `https://localhost:1313`. Hugo watches the
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
changes and rebuilds the site as needed. 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. or close the terminal window.
{{% /tab %}} {{% /tab %}}