stagex/packages/buf/Containerfile

37 lines
943 B
Text
Raw Normal View History

2024-04-22 22:08:41 +00:00
FROM scratch as base
ENV VERSION=1.30.1
ENV SRC_HASH=56da0c31b11bd15b99049af8b364c7bf4e11106152ab27d5ccb98d28123ab785
ENV SRC_FILE=v${VERSION}.tar.gz
ENV SRC_SITE=https://github.com/bufbuild/buf/archive/refs/tags/${SRC_FILE}
FROM base as fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
FROM fetch as build
COPY --from=stagex/busybox . /
COPY --from=stagex/go . /
COPY --from=stagex/ca-certificates . /
RUN tar -xvf v${VERSION}.tar.gz
WORKDIR buf-${VERSION}
ENV PWD=/home/user/buf-${VERSION}
ENV GOPATH=${PWD}/cache/go
ENV GOCACHE=${PWD}/cache/
ENV GOWORK=off
ENV GOPROXY=https://proxy.golang.org,direct
ENV GOSUMDB=sum.golang.org
ENV CGO_ENABLED=0
ENV GOHOSTOS=linux
ENV GOHOSTARCH=amd64
ENV GOFLAGS=-trimpath
RUN mkdir -p ${GOPATH}
RUN go build -o bin/buf ./cmd/buf
from build as install
RUN <<-EOF
mkdir -p /rootfs/usr/bin/
cp bin/buf /rootfs/usr/bin/
EOF
FROM stagex/filesystem as package
COPY --from=install /rootfs/./ /