Files
tanshu d04314ab1c Deploy with rootless podman + Quadlet on emily
Retargets the build and the playbook off rootful Docker on monoco, following the
conventions already in place on emily's other services: Quadlet units in
~/.config/containers/systemd, per-service data in ~/podman-data, and a shared
Caddy that every service registers itself with — a network drop-in plus a
marked block in its Caddyfile. Nothing is published on the host; Caddy reaches
the containers by name over mozimo_net.

- Makefile: podman build + push instead of docker buildx, PLATFORMS=linux/arm64
  (both hosts are aarch64). podman has no built-in QEMU the way buildx's builder
  image does, so a foreign-platform failure now points at qemu-user-static.
- deploy.sh: pass COMMIT= to make, which the Makefile actually reads; it was
  passing TAG=, so the tag silently came from `git rev-parse` instead.
- ansible: hosts emily, become false, XDG_RUNTIME_DIR for rootless podman and
  systemctl --user. Docker modules become Quadlet templates with user-service
  handlers, and the network role now ships mozimo.network plus the Caddy drop-in
  rather than calling docker_network.
- UserNS=keep-id maps the container's uid 1000 (node) and root (vince) onto the
  host user, so PocketBase and Vince write host-owned files instead of
  subuid-owned ones; the play asserts the pinned uid still matches the host.
- ansible/README.md: the unit layout, the service-registration convention, and
  the monoco -> emily migration (PocketBase 23 MB + Vince 119 MB, DNS cutover,
  rollback).

Verified by a check-mode rehearsal against emily (13 ok / 8 changed / 0 failed)
and a disposable Quadlet unit on that host proving the uid mapping, the
EnvironmentFile and the isolated network. The real build and cutover have not
been run.
2026-10-16 10:11:39 +05:30

44 lines
1.8 KiB
Makefile

COMMIT ?= $(shell git rev-parse --short HEAD)
# Both deployment hosts are aarch64, so that is the default target. A foreign
# platform needs the *host's* binfmt handlers — podman, unlike docker buildx,
# does not carry its own QEMU — hence the pointer in the failure path.
# Override with e.g. `make build-production PLATFORMS=linux/amd64`.
PLATFORMS ?= linux/arm64
IMAGE ?= registry.tanshu.com/mozimo
# Analytics ids baked into the client bundle — read from the local .env
# (gitignored) and passed to podman build. Empty values disable the tool.
VITE_ENV_KEYS := VITE_GA4_MEASUREMENT_ID VITE_PLAUSIBLE_DOMAIN VITE_SENTRY_DSN
BUILD_ARGS := $(shell for k in VITE_GA4_MEASUREMENT_ID VITE_PLAUSIBLE_DOMAIN VITE_SENTRY_DSN; do \
v=$$(grep -E "^$$k=" .env 2>/dev/null | head -1 | cut -d= -f2-); \
[ -n "$$v" ] && printf -- '--build-arg %s=%s ' "$$k" "$$v"; \
done; true)
BUILD_ARGS += --build-arg VITE_SENTRY_RELEASE=$(COMMIT) --build-arg SENTRY_RELEASE=$(COMMIT)
.PHONY: build-production
build-production: ## Build HEAD with podman for $(PLATFORMS); tag + push :$(COMMIT) and :main
@echo "▶ podman build --platform $(PLATFORMS) → $(IMAGE):$(COMMIT) + :main"
@git archive --format=tar HEAD | podman build \
--platform $(PLATFORMS) \
--tag $(IMAGE):$(COMMIT) \
--tag $(IMAGE):main \
$(BUILD_ARGS) \
- || { \
echo "✗ podman build failed."; \
echo " Cross-platform builds need binfmt on this host (podman has no built-in QEMU):"; \
echo " sudo apt install qemu-user-static # on an x86_64 host, for $(PLATFORMS)"; \
exit 1; \
}
podman push $(IMAGE):$(COMMIT)
podman push $(IMAGE):main
.PHONY: build-check
build-check: ## Compile check from HEAD with podman, nothing pushed
@git archive --format=tar HEAD | podman build \
--platform $(PLATFORMS) \
--tag mozimo:check \
--pull \
$(BUILD_ARGS) \
-