From 96377203b0ba35b19345528b429e10468007e6e9 Mon Sep 17 00:00:00 2001 From: Filip Pytloun Date: Thu, 6 Apr 2023 12:35:29 +0200 Subject: [PATCH] Multi-arch build --- .dockerignore | 2 ++ Dockerfile | 21 ++++++++++++++++++--- Makefile | 14 ++++++++++++++ README.md | 8 ++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Makefile create mode 100644 README.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..10769eb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Makefile +README.md diff --git a/Dockerfile b/Dockerfile index cb5c81a..adb1d56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,19 @@ -FROM restic/restic:0.15.1 -RUN apk add --no-cache jq curl +FROM golang:1.19-alpine AS builder -ENTRYPOINT ["/usr/local/bin/backup.sh"] +ENV RESTIC_VERSION 0.15.1 + +RUN apk add --no-cache git +RUN git clone --depth 1 --branch v${RESTIC_VERSION} https://github.com/restic/restic.git /go/src/github.com/restic/restic + +WORKDIR /go/src/github.com/restic/restic + +RUN go mod download +RUN go run build.go + +FROM alpine:latest AS restic + +RUN apk add --update --no-cache ca-certificates fuse openssh-client tzdata jq curl + +COPY --from=builder /go/src/github.com/restic/restic/restic /usr/bin + +ENTRYPOINT ["/usr/bin/restic"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5704a0d --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +ORG ?= genunix +VERSION = $(shell grep "ENV RESTIC_VERSION" Dockerfile | awk '{print $$3}') +PLATFORMS ?= linux/arm/v7,linux/arm64/v8,linux/amd64 + +build-all: print-version build-version build-latest + +print-version: + @echo "Building $(ORG)/restic:$(VERSION) for $(PLATFORMS)" + +build-version: + docker buildx build --push --platform $(PLATFORMS) --tag $(ORG)/restic:$(VERSION) . + +build-latest: + docker buildx build --push --platform $(PLATFORMS) --tag $(ORG)/restic:latest . diff --git a/README.md b/README.md new file mode 100644 index 0000000..064c431 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Restic Docker image + +Restic image for various platforms. + +## Build + +Just run `make` to build and push everything. Check `ORG` and `PLATFORMS` +variables to customize.