Update Dockerfile and Makefile to support dynamic Hugo version

Signed-off-by: Andrii Holovin <Andygol@users.noreply.github.com>
This commit is contained in:
Andrii Holovin 2024-11-13 20:39:56 +02:00
parent 18d293f987
commit abb751c85a
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,5 @@
FROM hugomods/hugo:node
ARG HUGO_VERSION=
FROM hugomods/hugo:node-${HUGO_VERSION}
WORKDIR /src

View File

@ -26,11 +26,15 @@ check-links-ci: set-up-link-checker run-link-checker
serve:
hugo server --buildDrafts --buildFuture --bind 0.0.0.0
HUGO_VERSION ?= $(shell grep HUGO_VERSION ./netlify.toml | head -1 | cut -d '"' -f 2)
IMAGE_NAME ?= helm-docs
image:
docker build -t helm-docs .
docker build --build-arg HUGO_VERSION=$(HUGO_VERSION) -t $(IMAGE_NAME) .
# Extract the target after 'image-run' or default to 'serve'
DOCKER_TARGET = $(if $(filter-out image-run,$(MAKECMDGOALS)),$(filter-out image-run,$(MAKECMDGOALS)),serve)
image-run:
docker run --rm --init -it -p 1313:1313 -v $(PWD):/src helm-docs $(DOCKER_TARGET)
docker run --rm --init -it -p 1313:1313 -v $(PWD):/src $(IMAGE_NAME) $(DOCKER_TARGET)