github.com/goreleaser/goreleaser@v1.25.1/www/docs/cookbooks/multi-platform-docker-images.md (about) 1 # Multi-platform Docker images 2 3 On GoReleaser there are two main ways of doing that: the easier one is to use 4 the [ko integration][ko]. 5 6 [ko]: /customization/ko 7 8 If you don't want to, or can't, use Ko for whatever reason, this guide is for 9 you! 10 11 ## Creating Multi-platform docker images with GoReleaser 12 13 GoReleaser splits the build and publish phase, which makes its usage less 14 obvious. 15 16 First, you need to define one `dockers` item for each platform you want to 17 build. Usually, you would tag it like `myorg/myimage:version-platform`. 18 It is also important to use `buildx`. Here's an example: 19 20 ```yaml 21 # .goreleaser.yaml 22 dockers: 23 - image_templates: 24 - 'myorg/myuser:{{ .Tag }}-amd64' 25 use: buildx 26 build_flag_templates: 27 - "--pull" 28 - "--platform=linux/amd64" 29 - image_templates: 30 - 'myorg/myuser:{{ .Tag }}-arm64' 31 use: buildx 32 build_flag_templates: 33 - "--pull" 34 - "--platform=linux/arm64" 35 goarch: arm64 36 37 ``` 38 39 This will, on build time, create two Docker images (`myorg/myuser:v1.2.3-amd64` 40 and `myorg/myuser:v1.2.3-arm64`). 41 42 Now, if we want to make them both available as a single image 43 (`myorg/myuser:v1.2.3`), we'll need to add a manifest configuration that will 44 publish them behind that single name. Here's how it would look like: 45 46 ```yaml 47 # .goreleaser.yaml 48 docker_manifests: 49 - name_template: 'myorg/myuser:{{ .Tag }}' 50 image_templates: 51 - 'myorg/myuser:{{ .Tag }}-amd64' 52 - 'myorg/myuser:{{ .Tag }}-arm64' 53 ``` 54 55 And that is it! 56 57 ## Other things to pay attention to 58 59 For `buildx` to work properly, you'll need to install `qemu`. On GitHub actions, 60 the easiest way is to use 61 [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action). 62 63 It's also important that the `FROM` in your `Dockerfile` is multi-platform, 64 otherwise it'll not work. 65 66 As long as you have Qemu and Docker set up, everything should just work.