2021-10-30 14:50:23 +02:00
|
|
|
# Docker Manifests
|
2020-11-28 21:26:37 +02:00
|
|
|
|
2022-09-17 05:13:09 +02:00
|
|
|
GoReleaser can also create and push Docker multi-platform images using the
|
|
|
|
`docker manifest` tool.
|
2020-11-28 21:26:37 +02:00
|
|
|
|
2022-09-17 05:13:09 +02:00
|
|
|
For it to work, it needs to be enabled in the
|
|
|
|
[client's configuration](https://github.com/docker/cli/blob/master/experimental/README.md).
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
Please make sure `docker manifest` works before opening issues.
|
|
|
|
|
2020-12-01 02:53:36 +02:00
|
|
|
Notice that if you have something in the `docker_manifests` section in your
|
2022-09-17 05:13:09 +02:00
|
|
|
config file, GoReleaser will add the manifest's to the release notes instead of
|
|
|
|
the Docker images names.
|
2020-12-01 02:53:36 +02:00
|
|
|
|
2021-11-21 17:57:07 +02:00
|
|
|
!!! warning
|
2022-09-17 05:13:09 +02:00
|
|
|
Notice that the images used in the manifest **need to be pushed** for this
|
|
|
|
to work. This is a limitation of how `docker manifest create` works. For
|
|
|
|
more info, check
|
|
|
|
[this issue](https://github.com/goreleaser/goreleaser/issues/2606).
|
2021-11-21 17:57:07 +02:00
|
|
|
|
2020-11-28 21:26:37 +02:00
|
|
|
## Customization
|
|
|
|
|
|
|
|
You can create several manifests in a single GoReleaser run, here are all the
|
|
|
|
options available:
|
|
|
|
|
|
|
|
```yaml
|
2021-12-23 02:52:01 +02:00
|
|
|
# .goreleaser.yaml
|
2020-11-28 21:26:37 +02:00
|
|
|
docker_manifests:
|
|
|
|
# You can have multiple Docker manifests.
|
|
|
|
-
|
2022-09-17 05:13:09 +02:00
|
|
|
# ID of the manifest, needed if you want to filter by it later on (e.g. on
|
|
|
|
# custom publishers).
|
2021-08-17 03:11:54 +02:00
|
|
|
id: myimg
|
|
|
|
|
2020-11-28 21:26:37 +02:00
|
|
|
# Name template for the manifest.
|
|
|
|
# Defaults to empty.
|
2023-01-20 17:01:08 +02:00
|
|
|
name_template: "foo/bar:{{ .Version }}"
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
# Image name templates to be added to this manifest.
|
|
|
|
# Defaults to empty.
|
|
|
|
image_templates:
|
2023-01-20 17:01:08 +02:00
|
|
|
- "foo/bar:{{ .Version }}-amd64"
|
|
|
|
- "foo/bar:{{ .Version }}-arm64v8"
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
# Extra flags to be passed down to the manifest create command.
|
|
|
|
# Defaults to empty.
|
|
|
|
create_flags:
|
|
|
|
- --insecure
|
|
|
|
|
|
|
|
# Extra flags to be passed down to the manifest push command.
|
|
|
|
# Defaults to empty.
|
|
|
|
push_flags:
|
|
|
|
- --insecure
|
2021-06-17 04:00:08 +02:00
|
|
|
|
2021-07-04 00:19:16 +02:00
|
|
|
# Skips the Docker manifest.
|
2023-01-20 17:01:08 +02:00
|
|
|
# If you set this to `false` or `auto` on your source Docker configs,
|
2021-06-17 04:00:08 +02:00
|
|
|
# you'll probably want to do the same here.
|
|
|
|
#
|
2023-01-20 17:01:08 +02:00
|
|
|
# If set to `auto`, the manifest will not be created in case there is an
|
2021-06-17 04:00:08 +02:00
|
|
|
# indicator of a prerelease in the tag, e.g. v1.0.0-rc1.
|
|
|
|
#
|
|
|
|
# Defaults to false.
|
|
|
|
skip_push: false
|
2021-07-04 00:19:16 +02:00
|
|
|
|
|
|
|
# Set the "backend" for the Docker manifest pipe.
|
|
|
|
# Valid options are: docker, podman
|
|
|
|
#
|
|
|
|
# Relevant notes:
|
|
|
|
# 1. podman is a GoReleaser Pro feature and is only available on Linux;
|
2022-09-17 05:13:09 +02:00
|
|
|
# 2. if you set podman here, the respective docker configs need to use podman
|
|
|
|
# too.
|
2021-07-04 00:19:16 +02:00
|
|
|
#
|
|
|
|
# Defaults to docker.
|
|
|
|
use: docker
|
2020-11-28 21:26:37 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
!!! tip
|
|
|
|
Learn more about the [name template engine](/customization/templates/).
|
|
|
|
|
|
|
|
## How it works
|
|
|
|
|
|
|
|
We basically build and push our images as usual, but we also add a new
|
2022-09-17 05:13:09 +02:00
|
|
|
section to our configuration defining, which images are part of which manifests.
|
2020-11-28 21:26:37 +02:00
|
|
|
|
2022-07-19 15:37:13 +02:00
|
|
|
GoReleaser will create and publish the manifest in its publishing phase.
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
!!! warning
|
|
|
|
Unfortunately, the manifest tool needs the images to be pushed to create
|
2022-07-19 15:37:13 +02:00
|
|
|
the manifest, that's why we both create and push it in the publishing phase.
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
## Example config
|
|
|
|
|
2020-12-28 22:32:40 +02:00
|
|
|
In this example we will use Docker's `--platform` option to specify the target platform.
|
2022-09-17 05:13:09 +02:00
|
|
|
This way we can use the same `Dockerfile` for both the `amd64`, and the `arm64`
|
2020-12-28 22:32:40 +02:00
|
|
|
images (and possibly others):
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
```dockerfile
|
|
|
|
# Dockerfile
|
2020-12-28 22:32:40 +02:00
|
|
|
FROM alpine
|
2020-11-28 21:26:37 +02:00
|
|
|
ENTRYPOINT ["/usr/bin/mybin"]
|
2021-01-07 21:21:12 +02:00
|
|
|
COPY mybin /usr/bin/mybin
|
2020-11-28 21:26:37 +02:00
|
|
|
```
|
|
|
|
|
2022-09-17 05:13:09 +02:00
|
|
|
Then, on our GoReleaser configuration file, we need to define both the
|
|
|
|
`dockers`, and the `docker_manifests` section:
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
```yaml
|
2021-12-23 02:52:01 +02:00
|
|
|
# .goreleaser.yaml
|
2020-11-28 21:26:37 +02:00
|
|
|
builds:
|
|
|
|
- env:
|
|
|
|
- CGO_ENABLED=0
|
|
|
|
binary: mybin
|
|
|
|
goos:
|
|
|
|
- linux
|
|
|
|
goarch:
|
|
|
|
- amd64
|
|
|
|
- arm64
|
|
|
|
dockers:
|
|
|
|
- image_templates:
|
|
|
|
- "foo/bar:{{ .Version }}-amd64"
|
2021-07-27 22:48:08 +02:00
|
|
|
use: buildx
|
2020-11-28 21:26:37 +02:00
|
|
|
dockerfile: Dockerfile
|
|
|
|
build_flag_templates:
|
2020-12-28 22:32:40 +02:00
|
|
|
- "--platform=linux/amd64"
|
2020-11-28 21:26:37 +02:00
|
|
|
- image_templates:
|
|
|
|
- "foo/bar:{{ .Version }}-arm64v8"
|
2021-07-27 22:48:08 +02:00
|
|
|
use: buildx
|
2020-11-28 21:26:37 +02:00
|
|
|
goarch: arm64
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
build_flag_templates:
|
2020-12-28 22:32:40 +02:00
|
|
|
- "--platform=linux/arm64/v8"
|
2020-11-28 21:26:37 +02:00
|
|
|
docker_manifests:
|
2023-01-20 17:01:08 +02:00
|
|
|
- name_template: "foo/bar:{{ .Version }}"
|
2020-11-28 21:26:37 +02:00
|
|
|
image_templates:
|
2023-01-20 17:01:08 +02:00
|
|
|
- "foo/bar:{{ .Version }}-amd64"
|
|
|
|
- "foo/bar:{{ .Version }}-arm64v8"
|
2020-11-28 21:26:37 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
!!! warning
|
2020-12-28 22:32:40 +02:00
|
|
|
Notice that `--platform` needs to be in the Docker platform format, not Go's.
|
2020-11-28 21:26:37 +02:00
|
|
|
|
|
|
|
That config will build the 2 Docker images defined, as well as the manifest,
|
|
|
|
and push everything to Docker Hub.
|
2021-07-04 00:19:16 +02:00
|
|
|
|
|
|
|
## Podman
|
|
|
|
|
2021-09-23 04:30:16 +02:00
|
|
|
!!! success "GoReleaser Pro"
|
|
|
|
The podman backend is a [GoReleaser Pro feature](/pro/).
|
|
|
|
|
2022-09-17 05:13:09 +02:00
|
|
|
You can use [`podman`](https://podman.io) instead of `docker` by setting `use`
|
|
|
|
to `podman` on your configuration:
|
2021-07-04 00:19:16 +02:00
|
|
|
|
|
|
|
```yaml
|
2021-12-23 02:52:01 +02:00
|
|
|
# .goreleaser.yaml
|
2021-07-04 00:19:16 +02:00
|
|
|
docker_manifests:
|
2023-01-20 17:01:08 +02:00
|
|
|
- name_template: "foo/bar:{{ .Version }}"
|
2021-07-04 00:19:16 +02:00
|
|
|
image_templates:
|
2023-01-20 17:01:08 +02:00
|
|
|
- "foo/bar:{{ .Version }}-amd64"
|
|
|
|
- "foo/bar:{{ .Version }}-arm64v8"
|
2021-07-04 00:19:16 +02:00
|
|
|
use: podman
|
|
|
|
```
|
|
|
|
|
2022-09-17 05:13:09 +02:00
|
|
|
Note that GoReleaser will not install Podman for you, nor change any of its
|
|
|
|
configuration.
|