Skip to content

Commit

Permalink
build(docker): build image using kos
Browse files Browse the repository at this point in the history
  • Loading branch information
thde committed Dec 13, 2023
1 parent 145ee18 commit ff4b7b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 44 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@ on:
- main
pull_request:

permissions:
contents: write # create releases
packages: write # push to ghcr

jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: WillAbides/[email protected]
with:
go-version: ^1.18
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
go-version: ^1.21.5
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -47,4 +42,3 @@ jobs:
args: release --clean ${{ env.GORELEASER_FLAGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
45 changes: 12 additions & 33 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env:
- KO_DOCKER_REPO=ghcr.io/{{ .Env.GITHUB_REPOSITORY }}
before:
hooks:
- go mod tidy
Expand All @@ -19,36 +21,13 @@ archives:
- format_overrides:
- goos: windows
format: zip
changelog:
skip: true
dockers:
- image_templates:
- "ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64"
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- image_templates:
- "ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8"
goarch: arm64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
docker_manifests:
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/{{ .Env.REPOSITORY_OWNER }}/{{ .ProjectName }}:{{ .Version }}-arm64v8
kos:
- base_image: cgr.dev/chainguard/static
bare: true
platforms:
- linux/amd64
- linux/arm64
tags:
- latest
- "{{.Tag}}"
creation_time: "{{.CommitTimestamp}}"

0 comments on commit ff4b7b9

Please sign in to comment.