Files
libnovel/justfile
Admin fd0f2afe16 feat: replace pb-init-v3.sh with PocketBase Go migrations
Adds a custom PocketBase binary (cmd/pocketbase) that embeds PocketBase as a
Go framework with version-controlled migrations, replacing the fragile 419-line
shell script. Migrations apply automatically on every `serve` startup.

Migration 1 (20260414000001): full baseline schema — all 21 collections, both
  indexes on chapters_idx, and initial superuser creation from env vars.
Migration 2 (20260414000002): adds three fields found in code but missing from
  the old script — books.rating, app_users.notify_new_chapters_push,
  book_comments.chapter.

docker-compose: pocketbase service now uses the custom kalekber/libnovel-pocketbase
image; pb-init one-shot container removed (migrations replace it entirely).

Existing installs: run `migrate history-sync` once to mark migration 1 as done,
then restart — migration 2 will apply the three previously missing fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-14 19:30:42 +05:00

137 lines
5.7 KiB
Makefile

# ── LibNovel v3 — justfile ────────────────────────────────────────────────────
# All commands that touch docker-compose are wrapped with `doppler run` so that
# secrets are injected into the environment at runtime — no .env files needed.
#
# Prerequisites:
# brew install doppler just
# doppler setup (run once; selects project=libnovel config=prd)
#
# Usage:
# just up # start all services (detached)
# just down # stop all services
# just logs # tail all service logs
# just ps # show running containers
# just build # rebuild backend + ui images
# just restart # full stop + start cycle
# just secrets # print all injected secrets (debug)
set dotenv-load := false # Doppler handles all env; never load a .env file
# ── Helpers ───────────────────────────────────────────────────────────────────
# Inject secrets from Doppler, then run the given command
doppler := "doppler run --"
# ── Core compose commands ─────────────────────────────────────────────────────
# Start all services in the background
up:
{{doppler}} docker compose up -d
# Start and stream logs (foreground)
up-fg:
{{doppler}} docker compose up
# Stop all running services
down:
{{doppler}} docker compose down
# Stop and remove volumes (full reset — destructive!)
down-volumes:
{{doppler}} docker compose down -v
# Show service status
ps:
{{doppler}} docker compose ps
# ── Build & publish ───────────────────────────────────────────────────────────
# Build (or rebuild) all custom images locally
build:
{{doppler}} docker compose build
# Build a specific service, e.g.: just build-svc backend
build-svc svc:
{{doppler}} docker compose build {{svc}}
# Push all custom images to Docker Hub (requires docker login)
push:
{{doppler}} docker compose push backend runner ui caddy pocketbase
# Build then push all custom images
build-push: build push
# Pull all images from Docker Hub (uses GIT_TAG from Doppler)
pull-images:
{{doppler}} docker compose pull backend runner ui caddy
# Pull all third-party base images (minio, pocketbase, etc.)
pull-infra:
{{doppler}} docker compose pull minio pocketbase meilisearch valkey postgres crowdsec watchtower
# ── Logs ─────────────────────────────────────────────────────────────────────
# Tail all service logs (last 50 lines + follow)
logs:
{{doppler}} docker compose logs -f --tail=50
# Tail a specific service, e.g.: just log backend
log svc:
{{doppler}} docker compose logs -f --tail=50 {{svc}}
# ── Lifecycle ─────────────────────────────────────────────────────────────────
# Full restart: stop then start
restart: down up
# Restart a single service, e.g.: just restart-svc backend
restart-svc svc:
{{doppler}} docker compose restart {{svc}}
# Pull → build → recreate (rolling update without clearing volumes)
update:
{{doppler}} docker compose pull
{{doppler}} docker compose build
{{doppler}} docker compose up -d
# ── Initialisation ────────────────────────────────────────────────────────────
# Run one-shot init containers (minio-init, pb-init, postgres-init)
init:
{{doppler}} docker compose run --rm minio-init
{{doppler}} docker compose run --rm pb-init
{{doppler}} docker compose run --rm postgres-init
# ── Shell access ──────────────────────────────────────────────────────────────
# Open a shell in a running service, e.g.: just shell backend
shell svc:
{{doppler}} docker compose exec {{svc}} sh
# ── Secrets ───────────────────────────────────────────────────────────────────
# Print all secrets Doppler will inject (never redirected to a file)
secrets:
doppler secrets --project libnovel --config prd
# Print secrets as a .env-formatted list (useful for debugging)
secrets-env:
doppler secrets download --project libnovel --config prd --format env --no-file
# Open Doppler dashboard in browser
secrets-dashboard:
doppler open dashboard
# ── Developer setup ───────────────────────────────────────────────────────────
# One-time dev setup: configure git to use committed hooks in .githooks/
setup:
git config core.hooksPath .githooks
@echo "Git hooks configured (.githooks/pre-commit active)."
# ── Gitea CI ──────────────────────────────────────────────────────────────────
# Validate workflow files
ci-lint:
actionlint .gitea/workflows/*.yaml