Browse Source

expand remote build to make file

imwald
Silberengel 5 days ago
parent
commit
3ebea1c7b4
  1. 72
      Makefile.hub
  2. 18
      README.md
  3. 1
      compose.hub.yaml

72
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 <target>)"
@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

18
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. 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): **Optional image / tag** (in `.env` or one-shot):
```bash ```bash
@ -159,14 +173,14 @@ docker compose -f compose.hub.yaml up -d
### One-time Nostr backfill (equivalent to `make prewarm` on dev) ### 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 ```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 articles:get -- '-2 month' 'now'
docker compose -f compose.hub.yaml exec -T php php bin/console app:prewarm 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 ### Scheduled `app:prewarm` on hub

1
compose.hub.yaml

@ -4,6 +4,7 @@
# docker compose -f compose.hub.yaml pull # docker compose -f compose.hub.yaml pull
# docker compose -f compose.hub.yaml up -d # docker compose -f compose.hub.yaml up -d
# docker compose -f compose.hub.yaml exec php php bin/console doctrine:migrations:migrate --no-interaction # 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). # 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`. # Optional: PREWARM_FLAGS in .env (same as dev `cron` service), then `docker compose up -d --force-recreate prewarm`.

Loading…
Cancel
Save