Test recipes locally with Docker Compose (#1)
scripts/local-test.sh starts a recipe the way Cottage runs it (parameters filled in, owned volumes without copy-up, default limits, no-new-privileges, localhost only), waits for its health path to answer 200 and cleans up. CI runs it on every pull request, forks included, alongside Cottage's own checks, which now live under .github/. The README explains the recipe format and rules for contributors.
This commit is contained in:
1 parent
a0d992022d
commit
193936ab2e
9 files changed
+215
-64
No files matched your search
@@ -1,57 +1,77 @@
|
||||
# Cottage catalog
|
||||
|
||||
The recipes behind every app on [Cottage](https://cottage.host), managed hosting for open-source
|
||||
apps. Each recipe is a Harbor template (Docker Compose plus a few Cottage settings) and a listing.
|
||||
Cottage's control plane syncs this repo and pushes the templates to the servers that run your apps.
|
||||
apps. A recipe is a Docker Compose file with a few Cottage settings, plus the listing people see
|
||||
when they choose an app.
|
||||
|
||||
Maintainers are welcome here: if you make one of these apps, you can check how we run it, suggest
|
||||
changes, or co-maintain its recipe. See Cottage's maintainer program for how revenue is shared.
|
||||
changes, or co-maintain its recipe. Cottage shares the revenue from each app with the people who
|
||||
make it; see the maintainer program on cottage.host.
|
||||
|
||||
```
|
||||
apps/<slug>/
|
||||
template.yml Harbor template: Compose + x-harbor (resources, parameters, health path)
|
||||
cottage.yml listing: name, tagline, category, upstream, license, image digests
|
||||
README.md first-run notes shown on the app's Overview tab
|
||||
template.yml Docker Compose file, with Cottage's settings in the x-harbor block
|
||||
cottage.yml listing: name, tagline, category, upstream, licence, image digests
|
||||
README.md first-run notes shown on the app's page in the dashboard
|
||||
icon.svg 64×64 icon, no scripts or event handlers
|
||||
tests/smoke.sh deploy → running → HTTP 200 on health_path → delete
|
||||
schema/cottage.schema.json
|
||||
scripts/local-test.sh
|
||||
```
|
||||
|
||||
## Rules
|
||||
## Writing a recipe
|
||||
|
||||
- **Slug** = directory name = `x-harbor.slug`, lowercase with hyphens, matching the upstream project.
|
||||
- **Version** = `<upstream version>-c<packaging revision>`, e.g. `1.34.3-c1`. Bump `-c` when only the
|
||||
recipe changes. A published version is never edited: Harbor and Hearth both refuse a changed
|
||||
document under an existing version.
|
||||
- Images come from the official upstream, pinned by tag in `template.yml`, with the multi-arch
|
||||
digest recorded in `cottage.yml`.
|
||||
- Containers run as a non-root user; `x-harbor.volumes` hands the volume to that uid/gid.
|
||||
`template.yml` is an ordinary Compose file. Its `x-harbor` block (Compose ignores `x-` keys) tells
|
||||
Cottage how to run it:
|
||||
|
||||
| Key | Meaning |
|
||||
| --- | --- |
|
||||
| `slug`, `name`, `description` | `slug` matches the directory name and the upstream project, lowercase with hyphens |
|
||||
| `version` | `<upstream version>-c<recipe revision>`, e.g. `1.34.3-c1` |
|
||||
| `primary` | the service and port that serve the app over HTTPS, e.g. `{ service: app, port: 8080 }` |
|
||||
| `health_path` | a path that answers 200 once the app is ready |
|
||||
| `default_resources`, `min_resources` | `cpu_millis`, `memory_mb`, `storage_mb` |
|
||||
| `volumes` | named volumes to hand to a non-root user: `data: { uid: 1000, gid: 1000, mode: "0750" }` |
|
||||
| `parameters` | settings people can see or change; secrets are generated (`generate: random32`, `random16` or `hex32`) |
|
||||
|
||||
Cottage provides `${HARBOR_PUBLIC_URL}` (the app's https:// address), `${HARBOR_HOSTNAME}`,
|
||||
`${HARBOR_SLUG}` and `${HARBOR_POD_ID}`, and every parameter as a variable of the same name.
|
||||
|
||||
Rules (CI checks them):
|
||||
|
||||
- Images from the official upstream, pinned by tag in `template.yml`, with the multi-arch digest
|
||||
recorded in `cottage.yml`.
|
||||
- Named volumes only. No host paths, published `ports`, `privileged`, `network_mode`, `cap_add`,
|
||||
or `deploy`/CPU/memory keys: Cottage sets the limits, the routing and the security options.
|
||||
- Containers run as a non-root user; list their volumes under `x-harbor.volumes` with that uid/gid.
|
||||
- First-run admin credentials are generated secret parameters, never defaults. If the app can only
|
||||
create its admin on first visit, set `first_visit_claims_admin: true` so the dashboard tells the
|
||||
owner to finish setup straight away.
|
||||
- Mail ports (25/465/587) are blocked by Harbor's egress firewall. Don't rely on SMTP.
|
||||
create its admin on first visit, set `first_visit_claims_admin: true` in `cottage.yml`, so the
|
||||
dashboard tells the owner to finish setup straight away.
|
||||
- Outgoing mail ports (25, 465, 587) are blocked. Don't rely on SMTP.
|
||||
- A published version is never edited, not even a comment. Change anything in a recipe and bump
|
||||
the `-c` revision.
|
||||
- Copy follows the Cottage voice: plain, warm, specific, sentence case, no exclamation marks.
|
||||
|
||||
## Testing a recipe
|
||||
|
||||
Each recipe has a smoke test (`apps/<slug>/tests/smoke.sh`): deploy, wait for it to run, check the
|
||||
health path, delete. CI runs every test against Harbor's fake runtime on each push and pull request.
|
||||
|
||||
Harbor isn't public yet, so CI needs a key to build it. Pull requests from forks can't use that
|
||||
key: their recipe tests are skipped, and we run them before merging.
|
||||
Run it locally with Docker Compose before opening a pull request:
|
||||
|
||||
```sh
|
||||
# With a Harbor node to test against (URL and API token):
|
||||
HARBOR_URL=http://127.0.0.1:7700 HARBOR_TOKEN=... apps/vaultwarden/tests/smoke.sh
|
||||
|
||||
# Against a real Docker node, also check the health path over HTTPS:
|
||||
HEALTH_BASE='https://%s' HARBOR_URL=... HARBOR_TOKEN=... apps/vaultwarden/tests/smoke.sh
|
||||
scripts/local-test.sh apps/vaultwarden
|
||||
KEEP=1 scripts/local-test.sh apps/vaultwarden # leave it running so you can try it in a browser
|
||||
```
|
||||
|
||||
The script starts the recipe close to the way Cottage runs it: parameters filled in, volumes owned
|
||||
by the right user, the default memory and CPU limits, no-new-privileges, and the app on
|
||||
`127.0.0.1` only. It passes when `health_path` answers 200, then removes everything it created. It
|
||||
needs Docker with Compose v2, `python3` and `curl`.
|
||||
|
||||
Every pull request runs the same test, plus Cottage's own checks of the recipe. Make sure both
|
||||
pass; we can't merge a recipe until they do. Pull requests from forks get the Compose test, and we
|
||||
run Cottage's checks before merging.
|
||||
|
||||
## Contributing
|
||||
|
||||
Open an issue or a pull request. Keep a recipe's published version unchanged: bump the `-c`
|
||||
revision instead. Please don't include secrets, real credentials or personal data.
|
||||
Open an issue or a pull request. Please don't include secrets, real credentials or personal data.
|
||||
|
||||
## Licence
|
||||
|
||||
|
||||
Reference in new issue
Block a user