1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/docs/130-docker.md

64 lines
1.6 KiB
Markdown
Raw Normal View History

---
title: Docker
---
Since [v0.31.0](https://github.com/goreleaser/goreleaser/releases/tag/v0.31.0),
GoReleaser supports building and pushing Docker images.
## How it works
You can declare multiple Docker images. They will be matched against
the binaries generated by your `builds` section.
If you have only one `build` setup,
the configuration is as easy as adding the
name of your image to your `.goreleaser.yml` file:
```yaml
dockers:
- image: user/repo
```
You also need to create a `Dockerfile` in your project's root folder:
```dockerfile
FROM scratch
COPY mybin /
ENTRYPOINT ["/mybin"]
```
This configuration will build and push a Docker image named `user/repo:tagname`.
## Customization
Of course, you can customize a lot of things:
```yaml
# .goreleaser.yml
dockers:
# You can have multiple Docker images.
-
# GOOS of the built binary that should be used.
goos: linux
# GOARCH of the built binary that should be used.
goarch: amd64
# GOARM of the built binary that should be used.
goarm: ''
# Name of the built binary that should be used.
binary: mybinary
# Docker image name.
image: myuser/myimage
# Path to the Dockerfile (from the project root).
dockerfile: Dockerfile
# Also tag and push myuser/myimage:latest.
2017-09-15 01:16:49 +02:00
latest: true
# If your Dockerfile copies files other than the binary itself,
# you should list them here as well.
extra_files:
- config.yml
```
These settings should allow you to generate multiple Docker images,
for example, using multiple `FROM` statements,
as well as generate one image for each binary in your project.