From df1cd414a1d2297070f53482ddc6f5055105c977 Mon Sep 17 00:00:00 2001 From: Carl Tashian Date: Wed, 10 Jul 2024 11:38:26 -0700 Subject: [PATCH] Build Docker images using goreleaser-pro instead of make --- docker/Dockerfile | 16 +++++++++++----- docker/Dockerfile.debian | 14 ++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8540e35f1..ba4931948 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,11 @@ -FROM --platform=$BUILDPLATFORM golang:alpine AS builder +FROM --platform=$BUILDPLATFORM goreleaser/goreleaser-pro:latest AS builder +# Note: goreleaser-pro:lates uses golang:alpine as base image WORKDIR /src COPY go.mod go.sum . RUN go mod download COPY . . -RUN apk add --no-cache make git curl +# RUN apk add --no-cache git curl ARG TARGETOS ARG TARGETARCH @@ -16,8 +17,13 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \ GOARM="${TARGETVARIANT#v}"; \ fi; \ - CGO_ENABLED=0 GOOS_OVERRIDE="GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" \ - make V=1 bin/step + CGO_ENABLED=0 \ + goreleaser build \ + --id default \ + --single-target \ + --auto-snapshot \ + --clean \ + --output bin/step FROM alpine @@ -40,4 +46,4 @@ WORKDIR /home/step STOPSIGNAL SIGTERM -CMD /bin/bash +CMD [ "/bin/bash" ] diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 7144443b8..066022652 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -4,8 +4,9 @@ WORKDIR /src COPY go.mod go.sum . RUN go mod download COPY . . +RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list RUN apt-get update \ - && apt-get install -y --no-install-recommends make git curl + && apt-get install -y --no-install-recommends curl goreleaser-pro ARG TARGETOS ARG TARGETARCH @@ -17,8 +18,13 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \ GOARM="${TARGETVARIANT#v}"; \ fi; \ - CGO_ENABLED=0 GOOS_OVERRIDE="GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM}" \ - make V=1 bin/step + CGO_ENABLED=0 \ + goreleaser build \ + --id default \ + --single-target \ + --auto-snapshot \ + --clean \ + --output bin/step FROM debian:bookworm @@ -41,4 +47,4 @@ WORKDIR /home/step STOPSIGNAL SIGTERM -CMD /bin/bash +CMD [ "/bin/bash" ]