Files
dnswatcher/Makefile
T
sneak 3c1dfe2575
check / check (push) Successful in 1m33s
docker: a plain docker build . stamps the git version (closes #210)
A plain `docker build .`, which is how upaas builds, stamped `dev`:
`.dockerignore` left out `.git` and the builder declared
`ARG VERSION=dev`. `.dockerignore` now sends `.git` and lists no tracked
file, which git in the build would count as deleted and mark `-dirty`.
`ARG VERSION` has no default. The Makefile takes `VERSION` from the
environment with `?=`, so a build arg still wins (`script/docker` keeps
passing one); otherwise `git describe` runs in the builder. A new
`make version` prints the version, and the builder fails when the
context carries `.git` and it comes out empty, `dev` or `unknown`.

Model: opus-5-5
2026-10-02 00:59:44 +00:00

52 lines
1.0 KiB
Makefile

.PHONY: all bootstrap setup build version lint fmt fmt-check test check clean hooks docker
BINARY := dnswatcher
# VERSION given on the command line (`make build VERSION=...`) or in the
# environment, which is how the Dockerfile's VERSION build arg arrives,
# wins over what `git describe` says of this checkout.
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -X main.Version=$(VERSION)
# Standard targets are thin shims; the implementations live in script/
# per the scripts-to-rule-them-all pattern (see the Entrypoints section
# of README.md).
all: check build
bootstrap:
@script/bootstrap
setup:
@script/setup
build:
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/dnswatcher
# Prints the version `make build` stamps; the Dockerfile checks it.
version:
@echo "$(VERSION)"
test:
@script/test
lint:
@script/lint
fmt:
@script/fmt
fmt-check:
@script/fmt-check
check:
@script/check
docker:
@script/docker
hooks:
@script/install-precommit
clean:
rm -rf bin/