Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 203 additions & 0 deletions docs/maintainers/adding-a-repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Adding a repository

Use this checklist when contributing a new Tuxcrate repository. Detailed release,
Renovate, infrastructure, and website behavior lives in the linked maintainer
guides. Keep repository READMEs short: the project name, a brief description,
and a documentation link.

## Establish the requirements

Before scaffolding a container repository, agree on:

- Name, visibility, upstream project URL, and a short description of what the
application does. Use `tuxcrate/<name>` and `ghcr.io/tuxcrate/<name>` unless
another destination is needed.
- Homepage URL: normally `https://tuxcrate.com/containers/<name>/`.
- Upstream license, redistribution requirements, and corresponding-source access.
New packaging repositories use AGPL-3.0 unless another license is agreed.
Include its full text in `LICENSE`; preserve upstream licenses and notices
separately in the image.
- Installation source and exact upstream version. Confirm that packages or
binaries exist for both `linux/amd64` and `linux/arm64`; finding one asset
does not establish availability for both architectures.
- Base-image tag and multiarchitecture manifest digest, verified against the
registry. Do not reuse an unrelated digest from another repository.
- Runtime requirements: user, writable directories, configuration, ports, mounts,
capabilities, and host dependencies.

Start with one stable track. Add prereleases or older maintained tracks only
when requested and supported upstream. Repository creation, pushes, GitHub
settings, infrastructure applies, and image publication require maintainer
approval; they are not validation steps.

## Scaffold the container repository

The normal layout is:

```text
.github/workflows/container.yml
.github/workflows/container-pr-cleanup.yml
.dockerignore
Containerfile
LICENSE
README.md
meta.yaml
renovate.json
tests/smoke.sh
```

Add dependency files and helper scripts only as needed. Use
[gallery-dl](https://github.com/tuxcrate/gallery-dl) as a PyPI reference,
[zrepl](https://github.com/tuxcrate/zrepl) for APT installation, and
[Lidarr](https://github.com/tuxcrate/lidarr) or
[Sonarr](https://github.com/tuxcrate/sonarr) for GitHub releases. Read the files
you reuse; do not copy application-specific paths, ports, pins, or Git history.

Keep `.git`, workflows, README, metadata, Renovate configuration, and host-side
tests out of the Docker build context unless the build actually needs them.
Host-side tests still count as release inputs even when excluded by
`.dockerignore`; see [the release-input comparison](container-releases.md#skipping-unchanged-releases).

### Release metadata and dependency updates

Declare every track in root `meta.yaml`. Build settings belong there, not in
workflow inputs. Each track needs a quoted exact version, a complete `baseImage`
reference with tag and verified digest, and explicit tags. Use `upstream`
discovery metadata so Renovate can update the application pin.

Stable tags normally include `${version}` and `latest`, with numeric series
aliases where useful. Numeric upstream prereleases need `prerelease: true` and
a suffixed image-version tag such as `${version}-prerelease`. They must not own
`latest` or unsuffixed numeric series aliases.

Metadata does not install the application. The Containerfile must configure the
package source or release download itself. Keep pins in metadata rather than
duplicating them in the Containerfile. Avoid extra `buildArgs` unless installation
genuinely needs another input. For branch-specific assets, use upstream release
metadata to select and verify the matching branch when possible.

Follow the [metadata schema and tag rules](container-releases.md#required-root-metadata-and-release-tracks)
and [image Renovate preset](dependency-updates.md#container-image-repositories).
Add local Renovate rules only for application-specific version formats or
release channels.

### Installation and runtime

Use the shared build-argument contract:

```dockerfile
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG APP_VERSION
```

Require `APP_VERSION` and install it exactly: `package==${APP_VERSION}` for PyPI,
`package=${APP_VERSION}` for APT, or the pinned release asset. Map download
architectures explicitly and verify checksums or signatures when provided. For
channel-specific downloads, check that the asset agrees with the upstream
release's channel.

Keep version, dependency, and installation assertions in the build. Do not start
a service during the build to test readiness; test the finished image through
the [host-side runtime smoke hook](container-tests.md).

Use user and group `tuxcrate` with UID/GID `1000:1000` when the application supports
non-root execution. For an Alpine service using `/config`, the account-creation
fragment is:

```dockerfile
RUN addgroup -g 1000 tuxcrate \
&& adduser -D -u 1000 -G tuxcrate -h /config -s /sbin/nologin tuxcrate \
&& mkdir -p /config \
&& chown 1000:1000 /config

USER 1000:1000
WORKDIR /config
```

Adapt the home and working directory to the application; CLI tools may use
`/home/tuxcrate` instead. Set a suitable entrypoint and default command, make
required directories writable, and retain valid OS identification in the final
image. Root-required applications must document why and declare
`com.tuxcrate.runtime-user="root"`, as described in
[shared runtime-user validation](container-tests.md#shared-runtime-user-validation).
The label does not grant host privileges.

The shared validator owns user/group identity checks. Repository smoke hooks own
application behavior and directory permissions. Use only
`com.tuxcrate.smoke-test` for test-container labels and clean up on exit. Never
pass credentials through build arguments or write them into images.

### Workflows

Add the [shared container caller](container-releases.md#calling-the-workflow)
and separate [PR-preview cleanup caller](container-releases.md#cleaning-up-pr-previews).
Do not duplicate shared build, test, or publishing jobs. Keep `uses` and
`shared-ref` coordinated when pinning shared tooling.

PRs test all active tracks and platforms without moving production tags.
Default-branch pushes can publish real releases. For an empty repository,
a README-only default branch followed by a container PR keeps the first
publication behind review. Do not push release workflows to the default branch
as a supposed dry run.

## Add the website page and GitHub configuration

In `tuxcrate/docs`, add `docs/containers/<name>.md` using the
[container-page format](website.md#image-pages). Provide the upstream URL,
description, topics, and independently verified Docker CLI and Compose examples.
Document required directories, ownership, configuration, capabilities, and host
dependencies before offering runnable examples.

Add fictional offline fixture coverage. Release tables are generated from GitHub
assets and verified GHCR tags; do not hand-maintain them. Coordinate live page
deployment with accessible release data.

With approval, register the repository in `tuxcrate/.github` infrastructure and
follow the [GitHub infrastructure guide](github-infrastructure.md). Import
existing repositories before managing them through OpenTofu. Set and verify the
GitHub About description and homepage, enable Renovate, and require
`container / pull-request-check` before merging container changes.

Verify GHCR visibility and Actions access for both production and preview
packages. Preview cleanup needs package admin access. Do not assume a workflow
token makes a newly created package public.

## Validate and submit

Before requesting review:

1. Validate `meta.yaml` with the shared `container-release plan` command, not
only a generic YAML parser. Build the CLI in `tuxcrate/github-actions`, then
run it from the image repository with `GITHUB_REPOSITORY=tuxcrate/<name>` and
a temporary `GITHUB_OUTPUT` path. Do not use `reserve`: it creates a real
draft release.
2. Run `actionlint` and
`renovate-config-validator --strict --no-global renovate.json` when available.
3. Build every active track uncached for both target platforms. Supply the planned
`BASE_IMAGE` and `APP_VERSION`, `--pull --no-cache`, and
`--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom`. Validate
finished images through the [shared artifact test and runtime hooks](container-tests.md#local-validation).
Report missing tooling or architecture support rather than claiming tests
passed.
4. Run the [website checks and a clean strict offline build](website.md#local-development)
for docs changes. Review the diff for copied names, placeholders, duplicated
pins, and credentials.

Use Conventional Commits for commits and PR titles, such as
`feat: add example container` or `docs: add example container page`. Keep changes
in the repositories they belong to; the workspace parent is not a Git repository.
Publish shared tooling changes before callers depend on them.

After the approved first release, verify public pulls, both platforms, immutable
revision tags, moving aliases, the GitHub release, and `release.json`. Check
documented runtime examples and preview visibility separately. Report files
changed, checks performed, and remaining configuration or publication steps.
Do not claim publication merely because a workflow was added.

## Non-container repositories

Use the general `github>tuxcrate/renovate-config` preset, keep the README short,
and add only the CI and documentation the project needs. Do not add container
metadata or release workflows to repositories that do not publish images.
57 changes: 49 additions & 8 deletions docs/maintainers/container-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ a preview package version without creating releases or consuming revisions.
2. Load each requested platform from the archive into the local Docker daemon
using Skopeo. Verify the archive contains exactly one matching platform image
and that the loaded image has the expected OS and architecture.
3. Run `tests/smoke.sh` once for each platform, when the hook exists. QEMU enables
3. Check the default runtime user, then run `tests/smoke.sh` once for each platform,
when the hook exists. QEMU enables
execution of non-native platforms on the GitHub runner. A failing hook fails
the track; there is no automatic retry of the entire test.
4. Validate release metadata, including OS identification from the first tested
Expand Down Expand Up @@ -50,6 +51,36 @@ checks its checksum before uploading. Missing receipts or modified archives
fail publication. These checks guard against accidental misuse; they cannot
protect against malicious code already executing on the runner.

## Shared runtime-user validation

Before running a repository hook, `container-artifact test` checks every loaded
platform image with its default user and no network, overriding only the
entrypoint to `/bin/sh`. Images must provide `/bin/sh` and `id`. The default
requirement is user and group `tuxcrate`, both with numeric ID 1000. The shared
check verifies all four values: UID, GID, username, and group name. It also runs
when the repository has no smoke hook.

Applications that require root must document the reason and declare it in the
Containerfile. For example:

```dockerfile
# ZFS administration requires root access to the host's ZFS devices.
LABEL com.tuxcrate.runtime-user="root"
```

This policy requires UID/GID `0:0` and user/group names `root`; it does not skip
validation. The optional label value `tuxcrate` declares the default explicitly.
Other nonempty values fail validation. The label does not change the configured
user or grant host privileges.

The shared validator owns runtime identity assertions. Keep application startup,
directory permissions, required tools, version/API checks, and shutdown behavior
in repository hooks. Do not repeat the four identity assertions once shared
validation is deployed, or start a service during an image build to test it.

Shared test containers and repository hooks use `com.tuxcrate.smoke-test`.
Cleanup recognizes only this label; there is no legacy-prefix fallback.

## Hook interface

Create a regular file at the repository root's `tests/smoke.sh`, regardless
Expand All @@ -63,7 +94,7 @@ bash tests/smoke.sh IMAGE APP_VERSION PLATFORM
| Argument | Meaning |
| --- | --- |
| `IMAGE` | Unique local Docker image reference loaded from the built archive; use it without pulling or rebuilding |
| `APP_VERSION` | Exact installation pin from the track, including an APT package revision when applicable |
| `APP_VERSION` | Expected upstream application version; for APT tracks, CI omits the Debian package revision |
| `PLATFORM` | Requested platform, such as `linux/amd64` or `linux/arm64` |

The hook also inherits `PACKAGE_VERSION` from the workflow. When an application
Expand All @@ -73,6 +104,10 @@ author link that the application does not actually read. Sonarr, Radarr, and
Prowlarr check their authenticated status APIs using the disposable instance's
generated API key.

The Containerfile still receives the full APT installation pin through its
`APP_VERSION` build argument and must install and assert that exact package.
Do not assume the similarly named hook argument includes the Debian revision.

The status request retries up to four times with a ten-second socket timeout per
request, allowing for slow first requests under QEMU. Once a request succeeds,
missing or incorrect package metadata fails immediately; it is not retried.
Expand All @@ -84,13 +119,13 @@ of hard-coding a release. Helpers and fixtures may live elsewhere under `tests/`
the pipeline does not automatically execute every file in that directory.

The runner supplies `TUXCRATE_TEST_ID`. Label every test container with
`io.tuxcrate.smoke-test=$TUXCRATE_TEST_ID` so the shared helper can remove it if
`com.tuxcrate.smoke-test=$TUXCRATE_TEST_ID` so the shared helper can remove it if
the hook times out or is interrupted. Each invocation has a five-minute timeout,
followed by a 30-second termination grace period. Hooks should use shorter
readiness and shutdown limits and their own cleanup traps.

Repositories without a hook keep their existing Containerfile assertions and
receive platform and OS-metadata validation, but no application-specific runtime
Repositories without a hook keep their installation assertions and receive
platform, runtime-user, and OS-metadata validation, but no application-specific runtime
smoke test. Repositories can therefore migrate individually; CI prints a notice
when the hook is missing.

Expand All @@ -99,7 +134,7 @@ when the hook is missing.
Run the production entrypoint as the image's configured user. Do not override
it to make startup pass. Check readiness through an application endpoint
where available, check the installed version, and confirm graceful shutdown.
Check runtime ownership, writable configuration directories, licenses, and
Check application directory ownership, writable configuration directories, licenses, and
required tools as appropriate for the application.

Use disposable container writable layers or volumes for generated data. Do not
Expand Down Expand Up @@ -133,8 +168,8 @@ trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM

container=$(docker create --pull=never --platform "$platform" \
--label "io.tuxcrate.smoke-test=${TUXCRATE_TEST_ID:-manual-$$}" "$image")
container=$(docker create --pull=never --platform "$platform" --network none \
--label "com.tuxcrate.smoke-test=${TUXCRATE_TEST_ID:-manual-$$}" "$image")
docker start "$container" >/dev/null

# Add bounded, application-specific readiness and exact-version checks here.
Expand Down Expand Up @@ -208,6 +243,12 @@ Remove the archive and its `.tested` receipt when they are no longer needed.

## Migrating an image repository

For the runtime-user policy, first migrate account names, explicit root
declarations, and smoke-test labels in callers. Deploy the shared validator
before removing duplicate identity checks from repository hooks. Keep these
changes separate when necessary so existing validation remains available during
the rollout.

Publish the shared workflow and helper changes before migrating callers.
For pinned workflows, keep `uses` and `with.shared-ref` on the same published
ref. Do not disable existing startup tests until the shared hook is available.
Expand Down
2 changes: 2 additions & 0 deletions docs/maintainers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Keep repository READMEs short and use these guides for shared setup instructions
development, and day-to-day operations.

- [Container releases](container-releases.md): workflow setup, metadata, build conventions, tags, publication, and failure recovery.
- [Container runtime tests](container-tests.md): shared user validation, host-side smoke hooks, and local image testing.
- [Adding a repository](adding-a-repository.md): contribution checklist for new container and non-container repositories.
- [Dependency updates](dependency-updates.md): shared Renovate presets.
- [GitHub infrastructure](github-infrastructure.md): OpenTofu validation, repository imports, and branch protection.
- [Website development](website.md): image pages, version tables, local development, and deployment.