From 0aa6079144d07ad8e2cd135a461d055f47dd3f9f Mon Sep 17 00:00:00 2001 From: Indra Gunawan <1284811+coderbuzz@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:02:43 +0700 Subject: [PATCH] feat: add Air live-reload dev setup with .env support - .air.toml: auto-watch .go + .html, rebuild & restart on change - .gitignore: add /tmp/ and .env - AGENTS.md: add Development Workflow and Git Workflow sections - TODO.md: removed (obsolete) --- .air.toml | 41 ++++++++++++++++++++++++++ .gitignore | 2 ++ AGENTS.md | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- TODO.md | 16 ---------- 4 files changed, 126 insertions(+), 19 deletions(-) create mode 100644 .air.toml delete mode 100644 TODO.md diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..3ce719e --- /dev/null +++ b/.air.toml @@ -0,0 +1,41 @@ +#:schema https://json.schemastore.org/any.json + +root = "." +tmp_dir = "tmp" + +env_files = [".env"] + +[build] +entrypoint = "dockify" +cmd = "go build -o ./tmp/dockify ./cmd/dockify" + delay = 1000 + env = ["DOCKIFY_DATA_DIR=./data"] + exclude_dir = ["assets", "tmp", "vendor", "data", "scripts"] + exclude_regex = ["_test\\.go"] + exclude_unchanged = true + full_bin = "DOCKIFY_DATA_DIR=./data ./tmp/dockify serve" + include_dir = ["cmd", "internal"] + include_ext = ["go", "html"] + kill_delay = "500ms" + log = "build-errors.log" + send_interrupt = true + stop_on_error = false + +[color] +app = "" +build = "yellow" +main = "green" +runner = "cyan" +watcher = "blue" + +[log] +main_only = false +time = false + +[misc] +clean_on_exit = true + +[screen] +clear_on_rebuild = false +keep_scroll = true + diff --git a/.gitignore b/.gitignore index 48cab62..48c827b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /data/ *.db /dockify +/tmp/ +.env diff --git a/AGENTS.md b/AGENTS.md index ea0d2ff..683e9c2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -149,22 +149,102 @@ Pushing a `v*` tag triggers `.github/workflows/build.yml` which automatically: No manual GitHub UI interaction needed. The install script auto-detects the latest release. -## Key Commands - +## Development Workflow + +This project uses [Air](https://github.com/air-verse/air) for live-reload during development. + +### Flow +1. **User** runs `air` in terminal (keeps it running) +2. **opencode** edits code/saves files +3. **Air** auto-detects changes → rebuilds Go binary → restarts server +4. **User** refreshes browser (Cmd+Shift+R) at `http://localhost:8080` to review +5. Repeat steps 2-4 until feature is complete +6. Only then release: `./scripts/release.sh patch` + +### How Air works +- Watches `.go` files in `cmd/` and `internal/` + `.html` files in `internal/http/templates/` +- On successful build: kills old process, starts new one +- On build error: **old server keeps running** (thanks to `stop_on_error = false`), error shown in terminal +- Data stored in `./data/` (SQLite DB), credentials in `.env` (both gitignored) +- Config: `.air.toml` at project root + +### Key development commands ```bash # Development go build ./... # build all packages go vet ./... # lint go mod tidy # clean dependencies -# Run locally +# Run locally (auto-reload) +air # http://localhost:8080 + +# Run once (no auto-reload) DOCKIFY_DATA_DIR=./data go run ./cmd/dockify serve +# Verify templates parse correctly +go test ./internal/http/... -run TestTemplates + # Build and run with Docker docker build -t dockify . docker run -p 8080:8080 -v $(pwd)/data:/var/lib/dockify dockify ``` +## Git Workflow + +### Branch Strategy +- `main` — stable, production-ready. Hanya diisi dari merge PR. +- `feat/*` — fitur baru +- `fix/*` — perbaikan bug + +### Daily Flow + +``` +main ───── feat/new-feature + │ │ + ├─ buat branch ┘ + │ ├─ kerja, commit (wip boleh), push + │ ├─ switch PC → pull, lanjut, push + │ │ (ulang sampai selesai) + │ │ + │ selesai + │ ├─ push final + │ ├─ gh pr create --fill + │ ├─ user: "merge" + │ ├─ gh pr merge --merge --delete-branch + │ └─ git branch -d feat/x + │ │ + ├─ merge ──────┘ + │ + ├─ ./scripts/release.sh patch + └─ push tag +``` + +### Step-by-step + +1. **opencode start task:** `git checkout main && git pull && git checkout -b feat/x` +2. **opencode kerja:** edit → commit → push (bisa WIP) +3. **Switch PC:** commit + push dulu di PC lama; `git pull` di PC baru, `git checkout feat/x` +4. **Selesai:** push final → `gh pr create --fill` +5. **User review:** user bilang "merge" kalau OK +6. **opencode merge:** `gh pr merge --merge --delete-branch && git branch -d feat/x && git checkout main` +7. **Release (dari main):** `./scripts/release.sh patch` + +### Commit Messages +``` +feat: add dark mode toggle +fix: handle empty server list +refactor: extract deploy logic +docs: update README +wip: partial work (feature branch only, never on main) +``` + +### Rules +- Tidak pernah commit/amend langsung di `main` +- Tidak pernah force push +- Tidak commit `.env`, token, atau secret +- Branch remote auto-hapus setelah merge, branch local dihapus manual +- Push dulu sebelum switch PC (biar bisa lanjut di perangkat lain) + ## Environment Variables | Variable | Default | Required | diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 0ded532..0000000 --- a/TODO.md +++ /dev/null @@ -1,16 +0,0 @@ -# TODO - -## Webhook Secret - -- [ ] **Settings page**: Add toggle to disable/clear the webhook secret. - - Currently the secret is auto-generated at startup (`internal/settings/settings.go:31` `ensureWebhookSecret()`) and cannot be disabled — only show/hide, copy, roll. - - Affected: `internal/http/templates/settings.html`, `internal/settings/settings.go`, `internal/settings/handler.go` - - After adding disable, update README Option A note to mention this feature. - -- [ ] **Settings template**: Replace hardcoded `dockify.amg.id` with a generic example domain in the GitHub Actions workflow snippet. - - File: `internal/http/templates/settings.html:33` - -## Backup - -- [ ] **Fix misleading YAML header comment**: `internal/backup/backup.go:95` says "Secrets (SSH keys, auth passwords if present) are included as saved" but SSH keys are **not** included in the export (`ExportServer` struct has no SSH key field). Either fix the comment or add SSH key export support. - - File: `internal/backup/backup.go:94-96`