From 7ed181c0f2034c6c546b3bf0bb0f88e4fac566c2 Mon Sep 17 00:00:00 2001 From: Oleg Isakov Date: Thu, 6 Mar 2025 15:41:18 +0200 Subject: [PATCH] build docker image for ghcr --- .github/workflows/release.yml | 12 +++++++++++- .goreleaser.yml | 29 ++++++++++++++++++++++++++++- Dockerfile | 6 ++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7df308..321269f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,16 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.23.x + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6 with: @@ -22,4 +32,4 @@ jobs: version: '~> v2' args: release --clean env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index d0b23c3..df0659f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -17,6 +17,33 @@ builds: goarch: - amd64 - arm64 + +dockers: + - image_templates: + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}-amd64" + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:latest-amd64" + dockerfile: Dockerfile + use: buildx + build_flag: + - "--platform=linux/amd64" + - image_templates: + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}-arm64" + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:latest-arm64" + dockerfile: Dockerfile + use: buildx + build_flag: + - "--platform=linux/arm64" + +docker_manifests: + - name_template: "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}" + image_templates: + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}-amd64" + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:{{ if not .IsSnapshot }}v{{ end }}{{ .Version }}-arm64" + - name_template: "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:latest" + image_templates: + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:latest-amd64" + - "ghcr.io/{{ .RepoOwner }}/{{ .ProjectName }}:latest-arm64" + archives: - format: zip name_template: >- @@ -26,4 +53,4 @@ archives: {{- .Arch }} checksum: name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' - algorithm: sha256 \ No newline at end of file + algorithm: sha256 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2211cc0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM alpine:latest + +RUN apk --no-cache add ca-certificates +COPY srvctl /usr/local/bin/srvctl + +ENTRYPOINT ["/usr/local/bin/srvctl"]