From 3ebea1c7b42c0280d9b2de07ca0e5b7b2de31742 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Thu, 23 Apr 2026 17:07:07 +0200 Subject: [PATCH] expand remote build to make file --- Makefile.hub | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++++-- compose.hub.yaml | 1 + 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 Makefile.hub diff --git a/Makefile.hub b/Makefile.hub new file mode 100644 index 0000000..d216bf8 --- /dev/null +++ b/Makefile.hub @@ -0,0 +1,72 @@ +# Hub / remote server (compose.hub.yaml only — no full repo needed). +# Copy this file next to compose.hub.yaml and .env, then e.g.: +# make -f Makefile.hub pull +# make -f Makefile.hub up +# make -f Makefile.hub migrate +# +# Override compose file: make -f Makefile.hub HUB_COMPOSE=compose.custom.yaml up + +HUB_COMPOSE ?= compose.hub.yaml +COMPOSE := docker compose -f $(HUB_COMPOSE) + +ARTICLES_FROM ?= -2 month +ARTICLES_TO ?= now + +.DEFAULT_GOAL := help + +.PHONY: help pull up down ps restart migrate prewarm-once articles-get backfill shell logs-php logs-prewarm logs-db + +help: + @echo "Hub deploy (use: make -f Makefile.hub )" + @echo " pull - docker compose pull" + @echo " up - start stack (detached)" + @echo " down - stop stack" + @echo " restart - down then up" + @echo " ps - service status" + @echo " migrate - run Doctrine migrations in php" + @echo " prewarm-once - one-shot app:prewarm in php (scheduled prewarm = prewarm service)" + @echo " articles-get - Nostr backfill (ARTICLES_FROM / ARTICLES_TO, see below)" + @echo " backfill - migrate + articles:get + prewarm-once (like dev make prewarm)" + @echo " shell - shell in php container" + @echo " logs-php - follow php logs" + @echo " logs-prewarm - follow prewarm sidecar logs" + @echo " logs-db - follow MySQL logs" + @echo "Variables: HUB_COMPOSE, ARTICLES_FROM (default: $(ARTICLES_FROM)), ARTICLES_TO (default: $(ARTICLES_TO))" + +pull: + $(COMPOSE) pull + +up: + $(COMPOSE) up -d + +down: + $(COMPOSE) down + +ps: + $(COMPOSE) ps + +restart: down up + +migrate: + $(COMPOSE) exec -T php php bin/console doctrine:migrations:migrate --no-interaction + +prewarm-once: + $(COMPOSE) exec -T php php bin/console app:prewarm + +articles-get: + $(COMPOSE) exec -T php php bin/console articles:get -- '$(ARTICLES_FROM)' '$(ARTICLES_TO)' + +backfill: up migrate articles-get prewarm-once + @echo "Backfill done." + +shell: + $(COMPOSE) exec php sh + +logs-php: + $(COMPOSE) logs -f php + +logs-prewarm: + $(COMPOSE) logs -f prewarm + +logs-db: + $(COMPOSE) logs -f database diff --git a/README.md b/README.md index 6b0f08e..80d4d86 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,20 @@ docker compose -f compose.hub.yaml exec php php bin/console doctrine:migrations: After code changes: **`pull` → `up -d`**; run **migrations** when the repo added new migration files. +### `Makefile.hub` (on the server) + +Copy **`Makefile.hub`** into the same directory as **`compose.hub.yaml`** and **`.env`** (no full clone required). You get short commands like the dev **`Makefile`**, all using `docker compose -f compose.hub.yaml` under the hood: + +```bash +make -f Makefile.hub help # list targets +make -f Makefile.hub pull +make -f Makefile.hub up +make -f Makefile.hub migrate +make -f Makefile.hub prewarm-once +make -f Makefile.hub articles-get # optional: ARTICLES_FROM='-1 year' ARTICLES_TO=now +make -f Makefile.hub backfill # up + migrate + articles-get + prewarm-once (closest to dev `make prewarm`) +``` + **Optional image / tag** (in `.env` or one-shot): ```bash @@ -159,14 +173,14 @@ docker compose -f compose.hub.yaml up -d ### One-time Nostr backfill (equivalent to `make prewarm` on dev) -`compose.hub` has no bind-mounted repo, so run the same commands **inside the `php` container** (after the stack is up and migrations have run): +Use **`make -f Makefile.hub backfill`**, or run the same **inside the `php` container**: ```bash docker compose -f compose.hub.yaml exec -T php php bin/console articles:get -- '-2 month' 'now' docker compose -f compose.hub.yaml exec -T php php bin/console app:prewarm ``` -Adjust the **articles:get** window as needed. +Adjust the **articles:get** window as needed (see **`Makefile.hub`** / `ARTICLES_FROM` / `ARTICLES_TO`). ### Scheduled `app:prewarm` on hub diff --git a/compose.hub.yaml b/compose.hub.yaml index 15c7ee6..535a9c4 100644 --- a/compose.hub.yaml +++ b/compose.hub.yaml @@ -4,6 +4,7 @@ # docker compose -f compose.hub.yaml pull # docker compose -f compose.hub.yaml up -d # docker compose -f compose.hub.yaml exec php php bin/console doctrine:migrations:migrate --no-interaction +# Optional: copy Makefile.hub into the same directory, then: make -f Makefile.hub help # # Services: `php` (web), `database` (MySQL), `prewarm` (same image; `app:prewarm` every 10 min — see README). # Optional: PREWARM_FLAGS in .env (same as dev `cron` service), then `docker compose up -d --force-recreate prewarm`.