From 18d293f9872c72b983b43d16fc1301f3b3d1fbbf Mon Sep 17 00:00:00 2001 From: Andrii Holovin Date: Tue, 12 Nov 2024 15:34:41 +0200 Subject: [PATCH 1/2] Add Dockerfile and .dockerignore with targets in Makefile Signed-off-by: Andrii Holovin --- .dockerignore | 23 +++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ Makefile | 12 ++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..d639ebad1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +# Ignore node_modules directory +node_modules + +# Ignore any log files +*.log + +# Ignore Dockerfile and .dockerignore itself +Dockerfile +.dockerignore + +# Ignore git repository files +.git +.gitignore + +# Ignore temporary files +tmp +*.tmp + +# Ignore build output +dist +build +resources +app diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2493e73aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM hugomods/hugo:node + +WORKDIR /src + +RUN apk update && apk add --no-cache make curl bash + +RUN npm install yarn + +COPY . . + +RUN npx yarn install + +EXPOSE 1313 + +ENTRYPOINT ["make"] diff --git a/Makefile b/Makefile index 73f9e16ad..6767b19f5 100644 --- a/Makefile +++ b/Makefile @@ -22,3 +22,15 @@ run-link-checker: bin/htmltest check-links-ci: set-up-link-checker run-link-checker + +serve: + hugo server --buildDrafts --buildFuture --bind 0.0.0.0 + +image: + docker build -t helm-docs . + +# 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) From abb751c85a5e1716bf001c7103898f8a4114184a Mon Sep 17 00:00:00 2001 From: Andrii Holovin Date: Wed, 13 Nov 2024 20:39:56 +0200 Subject: [PATCH 2/2] Update Dockerfile and Makefile to support dynamic Hugo version Signed-off-by: Andrii Holovin --- Dockerfile | 3 ++- Makefile | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2493e73aa..7b0ec108a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM hugomods/hugo:node +ARG HUGO_VERSION= +FROM hugomods/hugo:node-${HUGO_VERSION} WORKDIR /src diff --git a/Makefile b/Makefile index 6767b19f5..3a48d4628 100644 --- a/Makefile +++ b/Makefile @@ -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)