Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Docker images using goreleaser-pro instead of make #1230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -40,4 +46,4 @@ WORKDIR /home/step

STOPSIGNAL SIGTERM

CMD /bin/bash
CMD [ "/bin/bash" ]
14 changes: 10 additions & 4 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -41,4 +47,4 @@ WORKDIR /home/step

STOPSIGNAL SIGTERM

CMD /bin/bash
CMD [ "/bin/bash" ]