From ac6ebe73ff645c34cc0a4997901aedecce26856e Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Thu, 21 Dec 2023 17:14:41 +0800 Subject: [PATCH] fix: simplify docker build --- .github/workflows/build.yaml | 3 +- .goreleaser.yaml | 28 +++++++++++-------- deploy/go-cli-github/Dockerfile => Dockerfile | 5 ++-- 3 files changed, 21 insertions(+), 15 deletions(-) rename deploy/go-cli-github/Dockerfile => Dockerfile (52%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d895cfe..4e46ddf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -47,5 +47,6 @@ jobs: push: true tags: ${{ steps.docker_metadata.outputs.tags }} labels: ${{ steps.docker_metadata.outputs.labels }} - file: deploy/${{ matrix.binary }}/Dockerfile + file: Dockerfile + build-args: BINARY=${{ matrix.binary }} context: dist/${{ env.GITHUB_REPOSITORY_NAME }}_linux_amd64_v1 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3b2de82..e23507f 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -37,29 +37,33 @@ signs: artifacts: checksum dockers: -- image_templates: - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-amd64" +- ids: + - go-cli-github + image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-amd64" use: buildx - dockerfile: deploy/{{ .ArtifactName }}/Dockerfile build_flag_templates: + - "--build-arg=BINARY=go-cli-github" - "--platform=linux/amd64" -- image_templates: - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-arm64v8" +- ids: + - go-cli-github + image_templates: + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-arm64v8" use: buildx goarch: arm64 - dockerfile: deploy/{{ .ArtifactName }}/Dockerfile build_flag_templates: + - "--build-arg=BINARY=go-cli-github" - "--platform=linux/arm64/v8" docker_manifests: -- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}" +- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}" image_templates: - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-amd64" - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-arm64v8" -- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:latest" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-amd64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-arm64v8" +- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:latest" image_templates: - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-amd64" - - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/{{ .ArtifactName }}:{{ .Version }}-arm64v8" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-amd64" + - "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:{{ .Version }}-arm64v8" docker_signs: - args: diff --git a/deploy/go-cli-github/Dockerfile b/Dockerfile similarity index 52% rename from deploy/go-cli-github/Dockerfile rename to Dockerfile index 7d52a47..eef3093 100644 --- a/deploy/go-cli-github/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ FROM alpine:3.19@sha256:51b67269f354137895d43f3b3d810bfacd3945438e94dc5ac55fdac340352f48 -ENTRYPOINT ["/go-cli-github"] -COPY go-cli-github / +ARG BINARY=binary-build-arg-not-defined +ENTRYPOINT ["/${BINARY}"] +COPY $BINARY /