feat: add ship release and deploy skill
This commit is contained in:
1 parent
3d7e3adea1
commit
a9087b29f4
6 files changed
+216
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# Shared rules for every subagent brief
|
||||
|
||||
Paste this block, adapted, at the end of every brief.
|
||||
|
||||
```
|
||||
Hard rules:
|
||||
- DO NOT PUSH, do not create remote repos, do not tag remotely, do not deploy. The master agent does all of that after review.
|
||||
- Touch only your own repo. Other repos of this release are read only for you (another agent may be rewriting their history: no git commands that modify them).
|
||||
- Builds, tests and toolchains run ONLY in Docker, never on the host (no host go/node/npm). Reuse named volumes for module/build caches, e.g. -v <name>-gomod:/go/pkg/mod -v <name>-gocache:/root/.cache/go-build.
|
||||
- Before starting, record `docker images`, `docker volume ls`, `docker buildx ls` in your scratchpad. At the end remove every container, network, volume, buildx builder you created and every image you pulled or built that was not present before, then run `docker builder prune -f` for the build cache (in-use cache is never removed; parallel runs just rebuild). Do not remove pre-existing images, volumes or containers.
|
||||
- Commits: conventional, lowercase, imperative, optional scope, no trailing period (feat:, fix:, docs:, ci:, build:, chore:, test:, refactor:). One purpose per commit. New repos start with a commit named exactly `first commit` containing only LICENSE and a one-line README.md. Author/committer is the git global identity (Bryan Joshua Pedini). NO Co-Authored-By and no AI attribution trailers of any kind.
|
||||
- Files: no code comments except the two-line SPDX header on hand-written code files (dockerfile, makefile, scripts, source code), directly under the shebang if any, then one blank line:
|
||||
# SPDX-License-Identifier: <MIT for packaging/deployment repos, the project's license for source repos>
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
Comment syntax follows the file type. Config files (yaml, go.mod, .gitignore, README, LICENSE) get no header. File names: lowercase `dockerfile` and `makefile` (makefile starts with `#!make` then the header) unless the repo already uses another spelling.
|
||||
- Text: English, concise, no em dash anywhere, no emojis.
|
||||
- Never print or commit secrets. Tokens go through env vars or BuildKit secrets, never build args, layers, logs or files in the repo.
|
||||
- Report at the end: file list with a short description, commit list (hash + subject), exact build/test commands and results, anything the master must fill in or configure.
|
||||
```
|
||||
|
||||
## Environment facts for the master
|
||||
|
||||
- Gitea: git.bjphoster.com. Orgs: `source` (source code, GPL-2.0-or-later for Bryan's own code, upstream license kept for forks), `docker` (packaging repos building OCI images, MIT), `deployments` (compose stacks, MIT). Repos are private by default; package visibility follows the org.
|
||||
- `gt` CLI = Gitea CLI, logged in as site admin: `gt api /repos/<org>/<repo>`, `gt api -X POST /orgs/<org>/repos -d '{...}'`, `gt api -X PATCH /repos/<org>/<repo> -d '{"has_actions":true,"has_packages":true}'`.
|
||||
- Actions conventions (reference: docker/coredns-mysql, source/coredns-web-ui): vars `GIT_HOST`, `GIT_NAME`, `GIT_EMAIL`, `REGISTRY_USER`, secret `GIT_TOKEN` (some repos use `GITEA_TOKEN`; follow the reference repo you copy). Set them per repo via `gt api` (`/repos/<o>/<r>/actions/variables/<NAME>`, `/repos/<o>/<r>/actions/secrets/<NAME>`) if missing; never echo the token.
|
||||
- Runner: act_runner using the host Docker socket, amd64, job image ubuntu-latest. arm64 images are built by Go cross-compilation (`FROM --platform=$BUILDPLATFORM`, `GOARCH=$TARGETARCH`) with a runtime stage that runs no RUN steps under emulation, plus `docker buildx` (docker-container driver) for the multi-arch manifest. Do not rely on QEMU.
|
||||
- Deployment conventions: compose file starts with `---`; single HTTPS Traefik router only (labels under `### Section Træfik`, router `https-${TRAEFIK_ROUTER}`, `${TRAEFIK_MIDDLEWARES}`, `${TRAEFIK_MATCHRULE}` holding the full `Host(\`...\`)` in env, `tls=${TRAEFIK_TLSENABLED}`, `tls.certresolver=${TRAEFIK_CERTRESOLVER}`, service port label), external network `${TRAEFIK_NETWORK}`, no HTTP router, no Diun labels, no build in compose, `env.example` with a `# Træfik` block, `.gitignore` covering `.env` and the data dir, README with a Usage section. References: deployments/netbox-mcp-server, deployments/coredns-web-ui.
|
||||
- Hosts: stacks live in `/srv/<fqdn>`, owned by root, cloned from Gitea over HTTPS. Traefik per host in `/srv/<host>-traefik.<domain>` style dirs, certresolver usually `letsencrypt` (deSEC DNS challenge), middleware `hsts` defined by Traefik's own labels. `*.infra.bjphoster.cloud` resolves only internally.
|
||||
@@ -0,0 +1,18 @@
|
||||
# Deploy (master only)
|
||||
|
||||
Runs after the deployment repo is pushed and the image for every arch the host needs is in the registry.
|
||||
|
||||
1. Preflight on the host (`ssh -o BatchMode=yes <host>`): `uname -m` matches a published arch; `/srv/<fqdn>` does not exist (if it does, this is an update: go to Update); Traefik is running and the `traefik` network exists; the certificate for `<fqdn>` is in Traefik's acme store or the resolver can issue it; the image pulls (`docker pull <image>:<version>`; if the org is private, log in with a read-only token passed via stdin and `docker logout` afterwards, never leave credentials on the host unless the user asked).
|
||||
2. Clone: `git clone https://git.bjphoster.com/deployments/<name>.git /srv/<fqdn>` on `main`. For a private repo use a one-shot `-c http.extraHeader="Authorization: token ..."` from a file or env, not stored in `.git/config`, and confirm afterwards that `git remote -v` has no token.
|
||||
3. Configure: `cp env.example .env`, adjust host-specific values; create the data dirs and the config from the example; generate secrets on the host (`openssl rand -hex 24` or similar), write them only into `.env`/config with mode 600, and store a copy where the user expects it (ask if unknown; never print them in chat unless the user asks).
|
||||
4. Start: `docker compose pull && docker compose up -d`, then `docker compose ps` and logs until healthy.
|
||||
5. Verify end to end: from the host or the user's PC (whichever resolves the internal FQDN) `curl -sS -o /dev/null -w '%{http_code} %{ssl_verify_result}\n' https://<fqdn>/<health path>`; expect 200 (or the app's auth status) with a valid certificate. Check the app logs the real client IP, not Traefik's, if trusted proxies were configured.
|
||||
6. Remove any temporary Traefik helper that existed only to pre-issue the certificate (e.g. a `config/issue-cert.yml`) only if the user asked; otherwise mention it.
|
||||
|
||||
## Update (stack already deployed)
|
||||
|
||||
`cd /srv/<fqdn> && git pull --ff-only`, set `<NAME>_VERSION=<version>` in `.env`, `docker compose pull && docker compose up -d`, verify as above, then remove the previous image version on the host only if nothing else uses it.
|
||||
|
||||
## Native target (profile `full`, host without Docker)
|
||||
|
||||
If the user asks for a native deploy instead of the container: build with `make build-<arch>` in Docker locally, copy the binary and the unit, run `make install` on the host (or replicate its steps), `systemctl enable --now <name>`, verify as above. Confirm with the user first; the default deploy target is the container stack.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Deployment (deployments org) subagent brief
|
||||
|
||||
For profiles `full` and `container`. Template; append the shared rules from conventions.md.
|
||||
|
||||
```
|
||||
Create a new local git repo at ~/projects/deployments/<name> (if it exists, update it with new commits instead) that will become https://git.bjphoster.com/deployments/<name> (branch `main` only). Do not deploy anywhere.
|
||||
|
||||
What it deploys: <name> (<one line on what it is>) from the image `<image repo>:${<NAME>_VERSION}` where <image repo> is `git.bjphoster.com/docker/<name>` (full) or `git.bjphoster.com/source/<name>` (container); first version <version>; built elsewhere, the deployment must NOT build images. Read <source path> (and ~/projects/docker/<name> if it exists) for runtime details, read only: config example, docs, dockerfile. Runtime facts: <workdir, config path inside the image, default data/auth dirs, files the app writes at runtime, port, UI/health URLs>. Every path the app writes must be persistent; a config file the app rewrites must be a writable bind mount, not :ro. Check whether config can come from environment variables; if yes prefer env.example entries, otherwise ship an example config file and explain in the README where to copy it.
|
||||
|
||||
Target host: <host> (<arch>, <RAM>), deployed at /srv/<fqdn>, public name <fqdn>, behind Traefik <version> (external network `traefik` with subnet <subnet>, entrypoint `https`, certresolver `<resolver>`, middleware `hsts` from Traefik's labels; certificate for <fqdn> <already in acme.json | will be issued on first request>). Behind Traefik the app sees the proxy's address: configure trusted proxies / real-IP handling to cover <subnet> if the app supports it, and any "allow remote" switch the admin UI needs. <App-specific settings, e.g. routing strategy.>
|
||||
|
||||
Conventions (follow exactly; read every file and the git log of ~/projects/deployments/netbox-mcp-server and ~/projects/deployments/coredns-web-ui):
|
||||
- History: `first commit` with MIT LICENSE (Copyright (c) 2026 Bryan Joshua Pedini) and a one-line README.md, then a `<name> deployment` commit with docker-compose.yml (starting with `---`), env.example, .gitignore (.env and the data dir), a short README with a Usage section (cp env.example .env; docker compose up -d) and an Update section, plus any example config.
|
||||
- Single HTTPS Traefik router only, no HTTP router, no Diun labels; labels as in netbox-mcp-server. env.example `# Træfik` block with defaults for this host: TRAEFIK_MATCHRULE=Host(`<fqdn>`), router/service names like <fqdn with dots as underscores>, TRAEFIK_MIDDLEWARES=hsts, TRAEFIK_CERTRESOLVER=<resolver>, <NAME>_VERSION=<version>, data dir ./data, TZ=Europe/Rome.
|
||||
- Secrets never in the repo: placeholders like `changeme` in examples, real values generated on the host at deploy time.
|
||||
|
||||
Validate with `docker run --rm -v "$PWD":/w -w /w docker:cli docker compose --env-file env.example config` (docker:cli image; check it is present first, remove it afterwards if you pulled it). Add remote origin https://git.bjphoster.com/deployments/<name>.git, do not push.
|
||||
|
||||
Report: file list with a contents summary, commit list, and the exact steps to deploy on the host (files to create, where the config goes, which secrets to generate and how).
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
# Packaging (docker org) subagent brief
|
||||
|
||||
Only for profile `full`. Template; append the shared rules from conventions.md.
|
||||
|
||||
```
|
||||
Create a new local git repo at ~/projects/docker/<name> (create the directory; if it already exists, extend it instead and bump the pin) that will become the private Gitea repo https://git.bjphoster.com/docker/<name>. It builds an OCI image of <name> WITHOUT vendoring the source: the dockerfile pins a source version and downloads the source at image build time, like an AUR PKGBUILD / deb / rpm packaging repo. Read the source at <source path> only (another agent may be rewriting its history).
|
||||
|
||||
Context:
|
||||
- Source repo: https://git.bjphoster.com/source/<name>.git, <PRIVATE|public>. Release tag `<version>` (no v prefix). <One paragraph from the source's own Dockerfile/README: build command, entrypoint, workdir, config path, data/auth dirs, exposed port, health URL.> Prefer a static build (Go: CGO_ENABLED=0) if it builds and works; check whether upstream needs cgo.
|
||||
- Reference repo for layout, README style, license, workflow style, variable/secret names and commit style: ~/projects/coredns-mysql (remote docker/coredns-mysql). Read all its files: `dockerfile`, `versions.env`, `.dockerignore`, `.gitea/workflows/image.yaml`, scripts/, MIT LICENSE (Copyright (c) 2026 Bryan Joshua Pedini), history `first commit` then `feat: ...`.
|
||||
- Architectures: linux/amd64 and linux/arm64 in one manifest. Cross-compile in the build stage (FROM --platform=$BUILDPLATFORM, GOARCH=$TARGETARCH); the runtime stage must need no RUN steps under emulation, so QEMU is not required; build with docker buildx (create a docker-container builder in the workflow if needed, log in before `buildx build --push`). The runner is act_runner on the host docker socket; you cannot test it, keep the workflow robust.
|
||||
- Pin: `versions.env` with <NAME>_VERSION=<version> and <NAME>_COMMIT=<sha the tag resolves to, or TODO if the tag does not exist yet; tell me>. The build must verify the fetched tag resolves to the pinned commit and fail otherwise. Provide a build arg for the source URL (default https://git.bjphoster.com/source/<name>.git) for local overrides. If the source repo is private, the download takes the token as a BuildKit secret (`--secret id=git_token,env=GIT_TOKEN`), never a build arg or layer content.
|
||||
- Workflow `.gitea/workflows/image.yaml`: on tag push (tag must equal <NAME>_VERSION, fail otherwise) and workflow_dispatch build and push `${GIT_HOST}/docker/<name>` tagged `<version>`, plus `latest` only for non-prerelease versions (no `-` suffix); on push to main build only. Pass version/commit/build date into the binary metadata. Smoke test the amd64 image before publishing (start with a minimal config, request <health URL>, expect 200), in the reference repo's script style.
|
||||
- README.md: what the image is, how it is built (source pinned in versions.env, downloaded at build time), how to bump (edit versions.env, commit, tag the same version), runtime usage (config mount path, persistent volumes), CI vars/secrets.
|
||||
|
||||
Testing (Docker only): build both platforms locally with buildx, overriding the source URL to a local source (e.g. serve a bare clone of <source path> from a temporary container on a docker network, or a --build-context), using the current HEAD of the source repo as the pinned commit for the test, read with git without modifying that repo. Verify the arm64 binary is aarch64 (`file` in a container), run the amd64 image with a tiny config and get 200 from <health URL>, verify the token secret is in no layer and not in `docker history`.
|
||||
|
||||
Commits: `first commit` (LICENSE + one-line README), then single-purpose commits (e.g. `feat: add <name> image build`, `ci: build and publish multi-arch image`, `docs: ...`). Add remote origin https://git.bjphoster.com/docker/<name>.git, do not push.
|
||||
|
||||
Report: file list, commit list, exact local build/test commands and results, the value(s) left as TODO, the Gitea vars/secrets the workflow needs.
|
||||
```
|
||||
@@ -0,0 +1,56 @@
|
||||
# Source subagent brief
|
||||
|
||||
Template. Replace `<...>`, drop the blocks that do not apply to the profile, append the shared rules from conventions.md.
|
||||
|
||||
```
|
||||
Work in <source path> (<language/toolchain>, <"a fork of <upstream>" or "Bryan's own project">; read AGENTS.md / CLAUDE.md / README first). Branch <branch> has <N> local commits on top of <base ref> (<"upstream/main, already fetched, 0 behind" | "the last released tag <tag>" | "origin/main">):
|
||||
|
||||
<git log --format='%h %s' <base>..HEAD>
|
||||
|
||||
Goal 1, history: rewrite these into clear, single-purpose commits on top of <base>: one commit per feature / bugfix / docs / chore / test. A commit whose subject joins two things with "and" should be split if the parts are separable; a commit that sneaks unrelated changes (a fix to an earlier feature, a docs update, UI tweaks inside a routing commit) should have those parts moved to their own commit or folded into the commit they belong to. Each commit must build on its own (build + vet of touched packages at each commit; full test suite at the end). Use judgement; don't split for the sake of splitting. If the history is already clean, keep it and say so.
|
||||
|
||||
Constraints for the rewrite:
|
||||
- The final tree MUST be byte-identical to the current HEAD <sha> tree (`git diff <sha> HEAD` empty), except for the additions requested below and real bug fixes, each as its own commit, reported.
|
||||
- First create a backup ref: `git branch backup/pre-rewrite <sha>`. Leave it.
|
||||
- Non-interactive git only (no rebase -i): e.g. `git checkout -b work <base>`, recreate commits with `git checkout <sha> -- <paths>` / `git apply` of partial diffs, then move <branch> to the result.
|
||||
- Ignored dirs that hold tracked files (e.g. docs/) need `git add -f`.
|
||||
- Known flaky tests to ignore only if they fail under load and pass on rerun: <list or "none known">.
|
||||
```
|
||||
|
||||
## Profile `full`: native build and install (add to the brief)
|
||||
|
||||
```
|
||||
Goal 2, standalone: the source must run without Docker on linux amd64 and arm64. Add, as separate single-purpose commits after the rewritten history (e.g. `build: add makefile for native build and install`, `feat: add systemd unit`, `docs: document native install`):
|
||||
1. A root `makefile` if none exists (check first; reuse and extend an existing one instead), targets at least:
|
||||
- default `all`/`build`: native build with the host toolchain, static where possible (Go: CGO_ENABLED=0 if the project builds and works without cgo), version metadata injected (Go: -ldflags -X for Version/Commit/BuildDate from git describe / rev-parse / date), output ./<binary>;
|
||||
- `build-amd64`, `build-arm64` (GOOS=linux GOARCH=...);
|
||||
- `install`: binary to $(PREFIX)/bin (PREFIX=/usr/local, DESTDIR supported), systemd unit to /etc/systemd/system, example config to /etc/<name>/ only if not already present, state dir created, then `systemctl daemon-reload`;
|
||||
- `uninstall`, `test`, `debug` (unoptimized build with debug info, document it), `clean`, plus whatever the project needs.
|
||||
Privileges for install/uninstall: when not root (id -u != 0) run the privileged commands through `sudo`; if sudo is missing or fails (no password given), the target fails with a clear error. No sudo when already root.
|
||||
2. A ready-to-copy systemd unit in the repo (e.g. packaging/systemd/<name>.service) running the installed binary with its config in /etc/<name>/, state in /var/lib/<name> (set paths explicitly in the example config so nothing depends on HOME), Restart=on-failure, hardening (DynamicUser or a dedicated user, StateDirectory=, ConfigurationDirectory=, NoNewPrivileges, ProtectSystem=strict, ReadWritePaths for every path the program writes, including the config file if the program rewrites it). Verify the binary works under those constraints.
|
||||
3. Document make targets and the systemd install in the project docs and briefly in README.
|
||||
Test in Docker only: `make`, `make build-arm64` (check with `file` it is aarch64), `make test`; `make install` in a throwaway container as root and as a non-root user without sudo (must fail clearly); `systemd-analyze verify` the unit in a container, or boot it in a systemd-enabled container if feasible.
|
||||
```
|
||||
|
||||
## Profile `container`: image built by the source repo (add to the brief)
|
||||
|
||||
```
|
||||
Goal 2, image: the source repo owns its image (reference: source/coredns-web-ui). Verify, and add as separate commits only what is missing:
|
||||
- a lowercase `dockerfile` with a test target and a minimal runtime (scratch or distroless, non-root), multi-arch by cross-compilation (FROM --platform=$BUILDPLATFORM, GOARCH=$TARGETARCH), version metadata from build args;
|
||||
- `.gitea/workflows/test.yaml` (push on main) and `.gitea/workflows/image.yaml` (on tag push: validate the tag is semver equal to the version, build linux/amd64 + linux/arm64 with buildx, smoke test the amd64 image, push `${GIT_HOST}/source/<name>:<version>` and `latest` for non-prerelease tags).
|
||||
Test locally in Docker: build both platforms, check the arm64 binary is aarch64, run the amd64 image and hit <health endpoint> (expect 200).
|
||||
```
|
||||
|
||||
## Profile `bin`: release binaries only (add to the brief)
|
||||
|
||||
```
|
||||
Goal 2, release: check the release workflow in .gitea/workflows (reference: source/goreflex release.yml) produces the expected artifacts on tag push for version <version>; fix it in its own `ci:` commit if needed. Run the project's own build/test targets in Docker.
|
||||
```
|
||||
|
||||
## Closing block (all profiles)
|
||||
|
||||
```
|
||||
After the commits: create an annotated tag `<version>` (no v prefix, message "<name> <version>") on the final HEAD; no other tags. Ensure remote `origin` = https://git.bjphoster.com/source/<name>.git exists locally (add it if missing; keep `upstream` if present).
|
||||
|
||||
Report: final commit list (hash + subject + one line on contents), the tag SHA, confirmation that `git diff <sha> HEAD` is empty apart from the listed additions/fixes, test results.
|
||||
```
|
||||
Reference in new issue
Block a user