> Build ./Dockerfile and push it tagged with the release version.
> Source: https://orochibraru.com/releaser/docs/docker · Site index: https://orochibraru.com/llms.txt

# Docker Mode

Build `./Dockerfile` and push it tagged with the release version.

```yaml
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      packages: write
    steps:
      - uses: actions/checkout@v7
      - uses: orochibraru/releaser@v1
        with:
          docker: true
```

This runs `docker buildx build --push` on the repository root and pushes two
tags:

- `ghcr.io/<owner>/<repo>:X.Y.Z`
- `ghcr.io/<owner>/<repo>:latest`

A [prerelease](https://orochibraru.com/releaser/docs/trunk) pushes `:X.Y.Z-canary.N` and `:canary` (its id)
instead, and never moves `:latest`.

The image gets the `org.opencontainers.image.version` and
`org.opencontainers.image.source` labels, so GHCR links the package to the repo.
The GitHub release gets a `docker pull <image>:X.Y.Z` block appended to its
notes (`CHANGELOG.md` doesn't).

`:X.Y.Z` is pushed **before** the release commit and tag, so a failed build
leaves the repository untouched. `:latest` (or `:canary`) moves last, after the
tag and the GitHub release, so a rejected push never moves it. If moving it
fails, the error gives the `docker buildx imagetools create` command to finish
by hand.

## Registry and login

For `ghcr.io` images, the action logs in with its token as `GITHUB_ACTOR`. For
any other registry, set `docker-image` and log in first:

```yaml
- uses: docker/login-action@v4
  with:
    username: ${{ vars.DOCKERHUB_USERNAME }}
    password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: orochibraru/releaser@v1
  with:
    docker: true
    docker-image: docker.io/me/app
```

## Multi-arch

Multi-platform builds need QEMU and a buildx builder:

```yaml
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- uses: orochibraru/releaser@v1
  with:
    docker: true
    docker-platforms: linux/amd64,linux/arm64
```

Docker mode and [artifact mode](https://orochibraru.com/releaser/docs/artifacts) can be enabled together.

A runnable example lives in [`examples/docker`](https://github.com/orochibraru/releaser/blob/main/examples/docker).
