From 3288c8ed6f2f4752d50074c471ee3bf199bd4cb5 Mon Sep 17 00:00:00 2001 From: Jack Hickey Date: Thu, 26 Sep 2024 11:34:48 +0100 Subject: [PATCH 1/3] Add hugo version check and theme update to Makefile Update README.md with correct make target behaviors Add hugo-entrypoint to allow extra commands when docker starts Update hugo theme version in go.mod Use slimmer hugo docker image --- docs/Makefile | 33 ++++++++++++++------------------- docs/go.mod | 2 +- docs/go.sum | 2 ++ docs/hugo-entrypoint.sh | 4 ++++ 4 files changed, 21 insertions(+), 20 deletions(-) create mode 100755 docs/hugo-entrypoint.sh diff --git a/docs/Makefile b/docs/Makefile index 0781d904b5..bb62ce8b67 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,49 +1,45 @@ HUGO?=hugo -HUGO_IMG?=hugomods/hugo:0.134.1 +HUGO_VERSION?=$(shell hugo version 2>/dev/null | awk '{print $$2}' | cut -d '.' -f 2) +HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3 THEME_MODULE = github.com/nginxinc/nginx-hugo-theme -THEME_VERSION ?= $(shell curl -s https://api.github.com/repos/nginxinc/nginx-hugo-theme/releases/latest | jq -r ".tag_name") -ifeq (, $(shell ${HUGO} version 2> /dev/null)) -ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and Hugo are not installed. Hugo (<0.91) or Docker are required to build the local preview.) +ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true) + $(info Hugo is available and has a version greater than 133. Proceeding with build.) else - HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} hugo --bind 0.0.0.0 -p 1313 -endif + $(warning Hugo is not available or using a version less than 134. Attempting to use docker. HUGO_VERSION=$(HUGO_VERSION)) + HUGO=docker run --rm -it -v ${CURDIR}:/src -p 1313:1313 ${HUGO_IMG} /src/hugo-entrypoint.sh + ifeq (, $(shell docker version 2> /dev/null)) + $(error Hugo (>0.134) or Docker are required to build the local previews.) + endif endif -HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo - MARKDOWNLINT?=markdownlint MARKDOWNLINT_IMG?=ghcr.io/igorshubovych/markdownlint-cli:latest ifeq (, $(shell ${MARKDOWNLINT} version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and markdownlint are not installed. markdownlint or Docker are required to lint.) -endif else MARKDOWNLINT=docker run --rm -i -v ${CURDIR}:/src --workdir /src ${MARKDOWNLINT_IMG} endif +endif MARKDOWNLINKCHECK?=markdown-link-check MARKDOWNLINKCHECK_IMG?=ghcr.io/tcort/markdown-link-check:stable ifeq (, $(shell ${MARKDOWNLINKCHECK} --version 2> /dev/null)) ifeq (, $(shell docker version 2> /dev/null)) - $(error Docker and markdown-link-check are not installed. markdown-link-check or Docker are required to check links.) -endif else - MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/site --workdir /site ${MARKDOWNLINKCHECK_IMG} + MARKDOWNLINKCHECK=docker run --rm -it -v ${CURDIR}:/docs --workdir /docs ${MARKDOWNLINKCHECK_IMG} +endif endif + .PHONY: docs docs-draft docs-local clean hugo-get hugo-tidy lint-markdown link-check docs: ${HUGO} -docs-ci: - ${HUGO_CI} - watch: ${HUGO} --bind 0.0.0.0 -p 1313 server --disableFastRender @@ -51,11 +47,10 @@ drafts: ${HUGO} --bind 0.0.0.0 -p 1313 server -D --disableFastRender clean: - hugo mod clean [ -d "public" ] && rm -rf "public" hugo-get: - hugo mod get $(THEME_MODULE)@$(THEME_VERSION) + hugo mod get -u github.com/nginxinc/nginx-hugo-theme hugo-tidy: hugo mod tidy diff --git a/docs/go.mod b/docs/go.mod index f8d86c507e..fd1308b80c 100644 --- a/docs/go.mod +++ b/docs/go.mod @@ -2,4 +2,4 @@ module github.com/nginxinc/kubernetes-ingress/docs go 1.19 -require github.com/nginxinc/nginx-hugo-theme v0.41.17 // indirect +require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect diff --git a/docs/go.sum b/docs/go.sum index 1ba7251286..dbb193cdcb 100644 --- a/docs/go.sum +++ b/docs/go.sum @@ -1,2 +1,4 @@ github.com/nginxinc/nginx-hugo-theme v0.41.17 h1:KtF0TFQYXmVratjKVGEodWYFNbtxeOdrZLa9zi70BtA= github.com/nginxinc/nginx-hugo-theme v0.41.17/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= +github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo= +github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= diff --git a/docs/hugo-entrypoint.sh b/docs/hugo-entrypoint.sh new file mode 100755 index 0000000000..dc72123528 --- /dev/null +++ b/docs/hugo-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +hugo mod get -u github.com/nginxinc/nginx-hugo-theme +hugo $* From 49f58bc321cd59fa7ef98fe571f3510e63ba947f Mon Sep 17 00:00:00 2001 From: Jack Hickey Date: Thu, 26 Sep 2024 13:42:53 +0100 Subject: [PATCH 2/3] Fix docs-ci, bump go version --- docs/Makefile | 5 +++++ docs/go.mod | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index bb62ce8b67..2748c484f6 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,6 +4,8 @@ HUGO_IMG?=hugomods/hugo:std-go-git-0.134.3 THEME_MODULE = github.com/nginxinc/nginx-hugo-theme +HUGO_CI=docker run --rm -v ${CURDIR}:/src ${HUGO_IMG} hugo + ifeq ($(shell [ $(HUGO_VERSION) -gt 133 2>/dev/null ] && echo true || echo false), true) $(info Hugo is available and has a version greater than 133. Proceeding with build.) else @@ -40,6 +42,9 @@ endif docs: ${HUGO} +docs-ci: + ${HUGO_CI} + watch: ${HUGO} --bind 0.0.0.0 -p 1313 server --disableFastRender diff --git a/docs/go.mod b/docs/go.mod index fd1308b80c..79c50308f6 100644 --- a/docs/go.mod +++ b/docs/go.mod @@ -1,5 +1,5 @@ module github.com/nginxinc/kubernetes-ingress/docs -go 1.19 +go 1.23 require github.com/nginxinc/nginx-hugo-theme v0.41.19 // indirect From d639d85cd049b31f0dbefc6438172a1a2d36449f Mon Sep 17 00:00:00 2001 From: Jack Hickey Date: Thu, 26 Sep 2024 13:43:38 +0100 Subject: [PATCH 3/3] Run hugo-tidy --- docs/go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/go.sum b/docs/go.sum index dbb193cdcb..5dbffbf03f 100644 --- a/docs/go.sum +++ b/docs/go.sum @@ -1,4 +1,2 @@ -github.com/nginxinc/nginx-hugo-theme v0.41.17 h1:KtF0TFQYXmVratjKVGEodWYFNbtxeOdrZLa9zi70BtA= -github.com/nginxinc/nginx-hugo-theme v0.41.17/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M= github.com/nginxinc/nginx-hugo-theme v0.41.19 h1:CyZOhU8q0p3nQ+ZTFRx7c/Dq9rxV1mShADIHz0vDoHo= github.com/nginxinc/nginx-hugo-theme v0.41.19/go.mod h1:DPNgSS5QYxkjH/BfH4uPDiTfODqWJ50NKZdorguom8M=