From a5a7d7970fd711aef4b65790ee999369e85cbf1f Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Mon, 29 Mar 2021 20:43:46 +0200 Subject: [PATCH] Publish AMD64, ARM64, ARMv7 images for binary Signed-off-by: Hidde Beydals --- .gitignore | 3 +++ .goreleaser.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 2966ab63..2c230c7c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Release +dist/ + # Dependency directories (remove the comment below to include it) # vendor/ bin/ diff --git a/.goreleaser.yml b/.goreleaser.yml index e5e21beb..cc6fc2dd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -74,3 +74,64 @@ release: extra_files: - glob: ./output/manifests.tar.gz - glob: ./output/install.yaml +dockers: +- image_templates: + - 'fluxcd/flux-cli:{{ .Tag }}-amd64' + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64' + dockerfile: Dockerfile + use_buildx: true + goos: linux + goarch: amd64 + build_flag_templates: + - "--pull" + - "--build-arg=ARCH=linux/amd64" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.name={{ .ProjectName }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.source={{ .GitURL }}" + - "--platform=linux/amd64" +- image_templates: + - 'fluxcd/flux-cli:{{ .Tag }}-arm64' + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64' + dockerfile: Dockerfile + use_buildx: true + goos: linux + goarch: arm64 + build_flag_templates: + - "--pull" + - "--build-arg=ARCH=linux/arm64" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.name={{ .ProjectName }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.source={{ .GitURL }}" + - "--platform=linux/arm64" +- image_templates: + - 'fluxcd/flux-cli:{{ .Tag }}-arm' + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm' + dockerfile: Dockerfile + use_buildx: true + goos: linux + goarch: arm + goarm: 7 + build_flag_templates: + - "--pull" + - "--build-arg=ARCH=linux/arm" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.name={{ .ProjectName }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.source={{ .GitURL }}" + - "--platform=linux/arm/v7" +docker_manifests: +- name_template: 'fluxcd/flux-cli:{{ .Tag }}' + image_templates: + - 'fluxcd/flux-cli:{{ .Tag }}-amd64' + - 'fluxcd/flux-cli:{{ .Tag }}-arm64' + - 'fluxcd/flux-cli:{{ .Tag }}-arm' +- name_template: 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}' + image_templates: + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64' + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64' + - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4145caa3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM alpine:3.13 as builder + +RUN apk add --no-cache ca-certificates curl + +ARG ARCH=linux/amd64 +ARG KUBECTL_VER=1.20.4 + +RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/${ARCH}/kubectl \ + -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl && \ + kubectl version --client=true + +FROM alpine:3.13 as flux-cli + +# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries. +# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460 +RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf + +RUN apk add --no-cache ca-certificates + +COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/ +COPY --chmod=755 flux /usr/local/bin/ + +ENTRYPOINT [ "flux" ]