Skip to content

Commit

Permalink
Merge pull request #24 from samcm/feat/docker-rework
Browse files Browse the repository at this point in the history
feat: Goreleaser publish to docker
  • Loading branch information
samcm authored Aug 26, 2022
2 parents f054d3c + d0a989b commit d5a22c3
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 23 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: release

on:
push:
branches:
- 'master'
tags:
- 'v*.*.*'
pull_request:
# on:
# push:
# branches:
# - 'master'
# tags:
# - 'v*.*.*'
# pull_request:
jobs:
docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -37,12 +37,6 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ jobs:
-
name: Set up Go
uses: actions/setup-go@v3
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand Down
93 changes: 83 additions & 10 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
project_name: checkpointz

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
binary: app
goos:
- linux
- windows
- darwin

goarch:
- amd64
- arm64
goarm:
- 6
- 7
ignore:
- goarch: 386
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
mod_timestamp: "{{ .CommitTimestamp }}"
checksum:
name_template: 'checksums.txt'
snapshot:
Expand All @@ -31,3 +32,75 @@ changelog:
exclude:
- '^docs:'
- '^test:'

dockers:
- use: buildx
goos: linux
goarch: amd64
dockerfile: goreleaser.Dockerfile
image_templates:
- "samcm/{{ .ProjectName }}:{{ .Version }}-amd64"
- "samcm/{{ .ProjectName }}:latest-amd64"
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- use: buildx
goos: linux
goarch: arm64
dockerfile: goreleaser.Dockerfile
image_templates:
- "samcm/{{ .ProjectName }}:{{ .Version }}-arm64v8"
- "samcm/{{ .ProjectName }}:latest-arm64v8"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- use: buildx
goos: linux
goarch: arm64
dockerfile: goreleaser.Dockerfile
image_templates:
- "samcm/{{ .ProjectName }}:{{ .Version }}-arm64v7"
- "samcm/{{ .ProjectName }}:latest-arm64v8"
build_flag_templates:
- "--platform=linux/arm64/v7"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- use: buildx
goos: linux
goarch: arm64
dockerfile: goreleaser.Dockerfile
image_templates:
- "samcm/{{ .ProjectName }}:{{ .Version }}-arm64v6"
- "samcm/{{ .ProjectName }}:latest-arm64v8"
build_flag_templates:
- "--platform=linux/arm64/v6"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
docker_manifests:
- name_template: samcm/{{ .ProjectName }}:{{ .Version }}
image_templates:
- samcm/{{ .ProjectName }}:{{ .Version }}-amd64
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v8
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v7
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v6
- name_template: samcm/{{ .ProjectName }}:{{ .Version }}-arm64
image_templates:
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v8
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v7
- samcm/{{ .ProjectName }}:{{ .Version }}-arm64v6
- name_template: samcm/{{ .ProjectName }}:latest
image_templates:
- samcm/{{ .ProjectName }}:latest-amd64
- samcm/{{ .ProjectName }}:latest-arm64v8
- samcm/{{ .ProjectName }}:latest-arm64v7
- samcm/{{ .ProjectName }}:latest-arm64v6
3 changes: 3 additions & 0 deletions goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY app /app
ENTRYPOINT ["/app"]

0 comments on commit d5a22c3

Please sign in to comment.