forgejo-mcp-broker/Makefile

63 lines
2.1 KiB
Makefile
Raw Normal View History

# forgejo-mcp-broker Makefile
BINARY := fjmcp-broker
CMD_PKG := ./cmd/broker
MODULE := kode.naiv.no/olemd/forgejo-mcp-broker
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
GIT_REV := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w \
-X $(MODULE)/internal/buildinfo.Version=$(VERSION) \
-X $(MODULE)/internal/buildinfo.GitRevision=$(GIT_REV) \
-X $(MODULE)/internal/buildinfo.BuildDate=$(BUILD_DATE)
feat(deploy): rootless podman + Quadlet deployment (forgejo-mcp-broker-8yd) Adds a multi-stage Containerfile, Quadlet unit, and operator walkthrough for a production deploy. The broker spawns forgejo-mcp per session, so the image bundles both binaries — broker built from this repo, forgejo-mcp pinned via FORGEJO_MCP_VERSION build-arg (default 2.18.0). Image stages: 1. golang:alpine compiles the broker with ldflags-stamped buildinfo 2. golang:alpine clones forgejo-mcp at the pinned tag and compiles it 3. distroless static-nonroot copies both binaries; uid 65532 Persistent state via the named volume `fjmcp-state` mounted at /data. SQLite WAL + SHM sidecars live alongside broker.db on the same volume, so a container swap or image upgrade preserves all OAuth clients, issued tokens, and refresh-token history. Verified end-to-end: podman run --rm -d -v fjmcp-test-state:/data ... fjmcp-broker:test curl /healthz # store: ok, broker.db created podman stop fjmcp-test podman run --rm -d -v fjmcp-test-state:/data ... fjmcp-broker:test curl /healthz # store: ok, same broker.db ls volume → broker.db, broker.db-shm, broker.db-wal all present Quadlet unit (deploy/podman/fjmcp-broker.container) drops into ~/.config/containers/systemd/, reads secrets from a 0600 env file outside the unit, publishes :8080 on loopback for Caddy to front. Makefile gains `image` and `image-run` targets. README links to the new docs/deploy-podman.md walkthrough. Closes forgejo-mcp-broker-8yd. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 17:42:09 +02:00
.PHONY: all build test lint tidy clean help image image-run
IMAGE_NAME ?= ghcr.io/olemd/fjmcp-broker
IMAGE_TAG ?= latest
FORGEJO_MCP_VERSION ?= 2.18.0
all: build
build: ## Build the broker binary
go build -trimpath -ldflags '$(LDFLAGS)' -o $(BINARY) $(CMD_PKG)
test: ## Run tests with the race detector
go test -race ./...
lint: ## Static analysis (go vet; golangci-lint if installed)
go vet ./...
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not installed; skipping (go vet already ran)"; \
fi
tidy: ## Tidy go.mod / go.sum
go mod tidy
clean: ## Remove build artefacts
rm -f $(BINARY)
feat(deploy): rootless podman + Quadlet deployment (forgejo-mcp-broker-8yd) Adds a multi-stage Containerfile, Quadlet unit, and operator walkthrough for a production deploy. The broker spawns forgejo-mcp per session, so the image bundles both binaries — broker built from this repo, forgejo-mcp pinned via FORGEJO_MCP_VERSION build-arg (default 2.18.0). Image stages: 1. golang:alpine compiles the broker with ldflags-stamped buildinfo 2. golang:alpine clones forgejo-mcp at the pinned tag and compiles it 3. distroless static-nonroot copies both binaries; uid 65532 Persistent state via the named volume `fjmcp-state` mounted at /data. SQLite WAL + SHM sidecars live alongside broker.db on the same volume, so a container swap or image upgrade preserves all OAuth clients, issued tokens, and refresh-token history. Verified end-to-end: podman run --rm -d -v fjmcp-test-state:/data ... fjmcp-broker:test curl /healthz # store: ok, broker.db created podman stop fjmcp-test podman run --rm -d -v fjmcp-test-state:/data ... fjmcp-broker:test curl /healthz # store: ok, same broker.db ls volume → broker.db, broker.db-shm, broker.db-wal all present Quadlet unit (deploy/podman/fjmcp-broker.container) drops into ~/.config/containers/systemd/, reads secrets from a 0600 env file outside the unit, publishes :8080 on loopback for Caddy to front. Makefile gains `image` and `image-run` targets. README links to the new docs/deploy-podman.md walkthrough. Closes forgejo-mcp-broker-8yd. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 17:42:09 +02:00
image: ## Build the OCI image with rootless podman
BUILDAH_FORMAT=docker podman build \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--build-arg GIT_REVISION="$(GIT_REV)" \
--build-arg FORGEJO_MCP_VERSION="$(FORGEJO_MCP_VERSION)" \
-t $(IMAGE_NAME):$(IMAGE_TAG) \
.
image-run: image ## Build the image and run it locally with the example env
@test -f $$HOME/.config/fjmcp-broker.env || { \
echo "Create $$HOME/.config/fjmcp-broker.env first (see deploy/podman/fjmcp-broker.env.example)"; \
exit 1; }
podman run --rm -it \
--env-file $$HOME/.config/fjmcp-broker.env \
-e FJMCP_BROKER_LISTEN=:8080 \
-e FJMCP_BROKER_STORE=/data/broker.db \
-v fjmcp-state:/data:Z \
-p 127.0.0.1:8080:8080 \
$(IMAGE_NAME):$(IMAGE_TAG)
help: ## Show available targets
@awk 'BEGIN {FS = ":.*##"; print "Targets:"} /^[a-zA-Z_-]+:.*?##/ { printf " %-8s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)