www/GNUmakefile

49 lines
1.6 KiB
Text
Raw Normal View History

2023-02-04 23:50:00 +01:00
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
CACHEDIR=/tmp/hugo-cache-$(USER)
DESTDIR=public/
HOSTNAME=$(shell hostname)
2022-09-06 22:22:54 +02:00
REVISION=$(shell git rev-parse HEAD)
.PHONY: build
2022-11-09 00:12:27 +01:00
build: ## make build # builds an optimized version of the website in $(DESTDIR)
@echo "----- Generating site -----"
hugo --gc --minify --cleanDestinationDir -d $(DESTDIR) --cacheDir $(CACHEDIR)
2021-09-12 14:03:45 +02:00
cp public/index.json search/
cp public/search/index.html search/
(cd search && CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' ./search.go)
.PHONY: buildah
2022-11-09 00:12:27 +01:00
buildah: ## make buildah # builds the container images
deploy/build-image.sh
.PHONY: clean
2022-11-09 00:12:27 +01:00
clean: ## make clean # removed all $(DESTDIR) contents
@echo "----- Cleaning old build -----"
2021-09-12 14:03:45 +02:00
rm -f search/index.html search/index.json search/search
2021-10-28 21:22:36 +02:00
rm -rf $(DESTDIR)
2022-09-13 00:10:44 +02:00
.PHONY: deploy
2022-11-09 00:12:27 +01:00
deploy: ## make deploy # deploy the website the active kubernetes context
2022-09-13 00:10:44 +02:00
sed -i deploy/www.yaml -e 's/^\(\s*image:[^:]*:\).*$$/\1$(REVISION)/'
kubectl apply -f deploy/www.yaml
2023-02-04 23:50:00 +01:00
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
2022-09-08 20:06:09 +02:00
.PHONY: push
2022-11-09 00:12:27 +01:00
push: ## make push # push the built images to quay.io
2022-09-08 20:06:09 +02:00
buildah push adyxax/www quay.io/adyxax/www:$(REVISION)
buildah push adyxax/www-search quay.io/adyxax/www-search:$(REVISION)
.PHONY: serve
2022-11-09 00:12:27 +01:00
serve: ## make serve # hugo web server development mode
hugo serve --disableFastRender --noHTTPCache --cacheDir $(CACHEDIR) --bind 0.0.0.0 --port 1313 -b http://$(HOSTNAME):1313/
.DEFAULT_GOAL := help