~bigbes/sr-ht-dolt

1dc49e2ecffdcfd6e0503ef183771850451e5eab — Eugene Blikh 11 days ago bb8ce43
apk: ship dolt-git-hook as a -hook subpackage

The hook binary was the one piece of this repo not in the apk — the
deployment's Dockerfile.git cloned the repo and compiled it from source
at a separately pinned revision (SRHT_DOLT_HOOK_REV), which meant a
second version pin to keep in lockstep, a build-time dependency on the
git host, and a full Go toolchain stage in the git image rebuild.

Add dolt-git-hook to the Makefile's BINARIES (same guarded target
pattern) and split it into a dolt.sr.ht-hook subpackage: the git.sr.ht
container needs only this 9 MB binary, not the 126 MB doltsrht service
the main package carries. The deployment can now apk-add the subpackage
at the same pinned version as the service.
2 files changed, 19 insertions(+), 1 deletions(-)

M APKBUILD
M Makefile
M APKBUILD => APKBUILD +9 -0
@@ 17,6 17,10 @@ license="MIT"
# !tracedeps  — CGO_ENABLED=0 with -tags gms_pure_go, so the binaries are
#               static: no ICU, no gozstd, nothing to trace
options="!check !tracedeps"
# The hook subpackage carries dolt-git-hook alone: it is installed into the
# git.sr.ht container (as its post-update-script), not the dolt one, and
# pulling the full service package in there would drag doltsrht along.
subpackages="$pkgname-hook:hook"

source=""
builddir="$startdir"


@@ 58,3 62,8 @@ package() {
	# MIGRATIONDIR and STATICDIR are both derived from SHAREDIR, so they follow.
	make install PREFIX="$pkgdir/usr"
}

hook() {
	pkgdesc="post-update hook that provisions companion Dolt databases (for the git.sr.ht container)"
	amove usr/bin/dolt-git-hook
}

M Makefile => Makefile +10 -1
@@ 27,7 27,8 @@ GOBUILD=$(GO) build $(if $(GO_TAGS),-tags "$(GO_TAGS)",)

BINARIES=\
	doltsrht \
	doltsrht-migrate
	doltsrht-migrate \
	dolt-git-hook

# Default target builds the Go binaries only. CSS (all-share) is deliberately
# kept off the default path because sassc/minify are not always installed on


@@ 58,6 59,14 @@ doltsrht-migrate:
		echo "skip $@: ./cmd/doltsrht-migrate not present yet"; \
	fi

dolt-git-hook:
	@if [ -d ./cmd/dolt-git-hook ]; then \
		echo "$(GOBUILD) -o $@ ./cmd/dolt-git-hook"; \
		$(GOBUILD) -o $@ ./cmd/dolt-git-hook; \
	else \
		echo "skip $@: ./cmd/dolt-git-hook not present yet"; \
	fi

# Compile every buildable package; used as the CI build gate.
build:
	$(GOBUILD) ./...