Directly build restic binary in release Docker container

This commit is contained in:
Michael Eischer
2023-05-19 17:43:11 +02:00
parent 2293835242
commit 43fa051546
4 changed files with 28 additions and 23 deletions

View File

@@ -1,20 +1,18 @@
FROM --platform=$BUILDPLATFORM alpine:latest as helper
# the official binaries are cross-built from Linux running on an AMD64 host
# other architectures also seem to generate identical binaries but stay on the safe side
FROM --platform=linux/amd64 restic/builder:latest as helper
ARG VERSION
ARG TARGETOS
ARG TARGETARCH
# add release binary for the appropriate platform
COPY restic_${VERSION}_${TARGETOS}_${TARGETARCH}.bz2 /
RUN apk add --update --no-cache bzip2
RUN set -e && \
bzcat restic_${VERSION}_${TARGETOS}_${TARGETARCH}.bz2 > restic && \
chmod +x restic
COPY . /restic
RUN go run helpers/build-release-binaries/main.go --platform $TARGETOS/$TARGETARCH --skip-compress
RUN mv /output/restic_${TARGETOS}_${TARGETARCH} /output/restic
FROM alpine:latest
COPY --from=helper /restic /usr/bin
COPY --from=helper /output/restic /usr/bin
RUN apk add --update --no-cache ca-certificates fuse openssh-client tzdata jq
ENTRYPOINT ["/usr/bin/restic"]