- Dockerfile runs go test before building - Multi-stage: build+test stage, minimal alpine final image - Add gcc/musl-dev for CGO (sqlite) - Trim binaries with -s -w ldflags - Makefile with build, test, clean, docker targets - Version injection via ldflags
18 lines
396 B
Makefile
18 lines
396 B
Makefile
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
|
LDFLAGS := -ldflags "-X main.Version=$(VERSION)"
|
|
|
|
.PHONY: build test clean docker
|
|
|
|
build:
|
|
go build $(LDFLAGS) -o chatd ./cmd/chatd/
|
|
go build $(LDFLAGS) -o chat-cli ./cmd/chat-cli/
|
|
|
|
test:
|
|
DBURL="file::memory:?cache=shared" go test ./...
|
|
|
|
clean:
|
|
rm -f chatd chat-cli
|
|
|
|
docker:
|
|
docker build -t chat:$(VERSION) .
|