Skip to content

Commit

Permalink
Use goreleaser for docker images (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksanders authored Oct 19, 2020
1 parent cbbd933 commit 1a35afb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
22 changes: 20 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
Expand Down Expand Up @@ -38,3 +36,23 @@ changelog:
release:
draft: true
prerelease: auto
dockers:
- goos: linux
goarch: amd64
binaries:
- weep
image_templates:
- "netflix/{{.ProjectName}}:latest"
- "netflix/{{.ProjectName}}:{{ .Tag }}"
- "netflix/{{.ProjectName}}:v{{ .Major }}"
- "netflix/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}"
- "docker.pkg.github.com/netflix/{{.ProjectName}}/{{.ProjectName}}:latest"
- "docker.pkg.github.com/netflix/{{.ProjectName}}/{{.ProjectName}}:{{ .Tag }}"
- "docker.pkg.github.com/netflix/{{.ProjectName}}/{{.ProjectName}}:v{{ .Major }}"
- "docker.pkg.github.com/netflix/{{.ProjectName}}/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
ENV USER=docker
EXPOSE 9090
COPY weep-docker /weep
COPY weep /
ENTRYPOINT ["/weep"]
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ build-docker: weep-docker
docker build -t weep .
docker tag weep:latest $(REGISTRY)/infrasec/weep:$(DOCKER_TAG)

publish-docker:
docker push $(REGISTRY)/infrasec/weep:$(DOCKER_TAG)

docker: build-docker publish-docker
docker: build-docker

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,17 @@ make build-docker
docker run -v ~</optional/path/to/your/mtls/certs>:</optional/path/to/your/mtls/certs> --rm weep --meta-data --role <roleArn>
```

#### Publishing a Docker image
### Releasing

To publish a Docker image, you can invoke `make docker`, which runs `make build-docker` and `make publish-docker`. When run from any branch other than `master`, the image is tagged with the version number and branch name. On the `master` branch the image is tagged with only the version number.
Weep uses [goreleaser](https://goreleaser.com/) in Github Actions for releases. Check their
[install docs](https://goreleaser.com/install/) if you would like to experiment with the release process locally.

> To update the version number, change the `VERSION` variable in `Makefile`.
To create a new release, create and push a tag containing the [semantic version](https://semver.org/):

```bash
git tag -am "v1.2.3" v1.2.3
git push origin v1.2.3
```

Goreleaser will create a draft release on the [Releases page](https://github.com/Netflix/weep/releases). If everything
looks good, press Publish and the release will be made public.

0 comments on commit 1a35afb

Please sign in to comment.