# syntax=docker/dockerfile:1.8-labs FROM --platform=linux/amd64 golang:1.24-alpine AS build ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT ENV GOOS=$TARGETOS GOARCH=$TARGETARCH RUN apk add --no-cache make git WORKDIR /go/src/github.com/hairyhenderson/gomplate COPY go.mod /go/src/github.com/hairyhenderson/gomplate COPY go.sum /go/src/github.com/hairyhenderson/gomplate RUN --mount=type=cache,id=go-build-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/root/.cache/go-build \ --mount=type=cache,id=go-pkg-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/go/pkg \ go mod download -x COPY . /go/src/github.com/hairyhenderson/gomplate RUN --mount=type=cache,id=go-build-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/root/.cache/go-build \ --mount=type=cache,id=go-pkg-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},target=/go/pkg \ make build RUN mv bin/gomplate* /bin/ FROM scratch AS gomplate-linux ARG VCS_REF ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT LABEL org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.source="https://github.com/hairyhenderson/gomplate" COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=build /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT} /gomplate ENTRYPOINT [ "/gomplate" ] FROM alpine:3.21 AS gomplate-alpine ARG VCS_REF ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT LABEL org.opencontainers.image.revision=$VCS_REF \ org.opencontainers.image.source="https://github.com/hairyhenderson/gomplate" COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=build /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT} /bin/gomplate ENTRYPOINT [ "/bin/gomplate" ] FROM --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:ltsc2022 AS gomplate-windows ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT COPY --from=build /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.exe /gomplate.exe FROM gomplate-$TARGETOS AS gomplate