github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/www/docs/customization/docker_manifest.md (about)

     1  ---
     2  title: Docker Manifest
     3  ---
     4  
     5  Since [v0.148.0](https://github.com/goreleaser/goreleaser/releases/tag/v0.148.0),
     6  GoReleaser supports building and pushing Docker multi-platform images through
     7  the `docker manifest` tool.
     8  
     9  For it to work, it [has to be enabled in the client configurations](https://github.com/docker/cli/blob/master/experimental/README.md).
    10  
    11  Please make sure `docker manifest` works before opening issues.
    12  
    13  Notice that if you have something in the `docker_manifests` section in your
    14  config file, GoReleaser will add the manifest's to the release notes
    15  instead of the Docker images names.
    16  
    17  !!! warning
    18      Please note that this is a beta feature, and it may change or be removed
    19      at any time.
    20  
    21  ## Customization
    22  
    23  You can create several manifests in a single GoReleaser run, here are all the
    24  options available:
    25  
    26  ```yaml
    27  # .goreleaser.yml
    28  docker_manifests:
    29    # You can have multiple Docker manifests.
    30  -
    31    # Name template for the manifest.
    32    # Defaults to empty.
    33    name_template: foo/bar:{{ .Version }}
    34  
    35    # Image name templates to be added to this manifest.
    36    # Defaults to empty.
    37    image_templates:
    38    - foo/bar:{{ .Version }}-amd64
    39    - foo/bar:{{ .Version }}-arm64v8
    40  
    41    # Extra flags to be passed down to the manifest create command.
    42    # Defaults to empty.
    43    create_flags:
    44    - --insecure
    45  
    46    # Extra flags to be passed down to the manifest push command.
    47    # Defaults to empty.
    48    push_flags:
    49    - --insecure
    50  ```
    51  
    52  !!! tip
    53      Learn more about the [name template engine](/customization/templates/).
    54  
    55  ## How it works
    56  
    57  We basically build and push our images as usual, but we also add a new
    58  section to our config defining which images are part of which manifests.
    59  
    60  GoReleaser will create and publish the manifest in its publish phase.
    61  
    62  !!! warning
    63      Unfortunately, the manifest tool needs the images to be pushed to create
    64      the manifest, that's why we both create and push it in the publish phase.
    65  
    66  ## Example config
    67  
    68  In this example we will use Docker's `--platform` option to specify the target platform.
    69  This way we can use the same `Dockerfile` for both the `amd64` and the `arm64`
    70  images (and possibly others):
    71  
    72  ```dockerfile
    73  # Dockerfile
    74  FROM alpine
    75  ENTRYPOINT ["/usr/bin/mybin"]
    76  COPY mybin /usr/bin/mybin
    77  ```
    78  
    79  Then, on our GoReleaser config file, we need to define both the `dockers` and
    80  the `docker_manifests` section:
    81  
    82  ```yaml
    83  # .goreleaser.yml
    84  builds:
    85  - env:
    86    - CGO_ENABLED=0
    87    binary: mybin
    88    goos:
    89    - linux
    90    goarch:
    91    - amd64
    92    - arm64
    93  dockers:
    94  - image_templates:
    95    - "foo/bar:{{ .Version }}-amd64"
    96    use_buildx: true
    97    dockerfile: Dockerfile
    98    build_flag_templates:
    99    - "--platform=linux/amd64"
   100  - image_templates:
   101    - "foo/bar:{{ .Version }}-arm64v8"
   102    use_buildx: true
   103    goarch: arm64
   104    dockerfile: Dockerfile
   105    build_flag_templates:
   106    - "--platform=linux/arm64/v8"
   107  docker_manifests:
   108  - name_template: foo/bar:{{ .Version }}
   109    image_templates:
   110    - foo/bar:{{ .Version }}-amd64
   111    - foo/bar:{{ .Version }}-arm64v8
   112  ```
   113  
   114  !!! warning
   115      Notice that `--platform` needs to be in the Docker platform format, not Go's.
   116  
   117  That config will build the 2 Docker images defined, as well as the manifest,
   118  and push everything to Docker Hub.