Skip to content

Commit

Permalink
GoReleaser: add Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
talal committed Aug 14, 2020
1 parent 036ae02 commit f7b75e6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
with:
go-version: 1.14

- name: Docker Login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
run: |
echo "${DOCKER_ACCESS_TOKEN}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Generate release info
run: make build/release-info

Expand All @@ -33,3 +40,8 @@ jobs:
args: release --rm-dist --release-notes=./build/release-info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Cleanup
if: always()
run: |
rm -f ${HOME}/.docker/config.json
16 changes: 16 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ builds:
archives:
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"

dockers:
- image_templates:
- "sapcc/absent-metrics-operator:{{ .Tag }}"
- "sapcc/absent-metrics-operator:v{{ .Major }}.{{ .Minor }}"
- "sapcc/absent-metrics-operator:latest"
dockerfile: Dockerfile.goreleaser
binaries:
- absent-metrics-operator
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.version={{.Version}}"

checksum:
name_template: "checksums.txt"

Expand Down
10 changes: 10 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# We use this additional file instead of the other Dockerfile because
# GoReleaser already compiles a static binary and we can just copy it over
# compared to the other Dockerfile which first compiles it.
#
# This saves extra work and time in our CI release workflow.
FROM alpine:latest

RUN apk add --no-cache ca-certificates
COPY absent-metrics-operator /usr/bin/
ENTRYPOINT [ "/usr/bin/absent-metrics-operator" ]

0 comments on commit f7b75e6

Please sign in to comment.