forked from instrumentisto/restic-docker-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (48 loc) · 1.5 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# Stage `dist` creates restic distribution.
#
# https://hub.docker.com/_/golang
FROM golang:1.22-alpine3.20 AS dist
ARG restic_ver=0.17.3
ARG build_rev=0
# Install build tools.
RUN apk add --update --no-cache \
build-base curl git
# Prepare dirs for export.
RUN mkdir -p /out/usr/local/bin/ \
/out/usr/share/licenses/restic/
# Download restic.
RUN curl -fL -o /tmp/restic.tar.gz \
https://github.com/restic/restic/releases/download/v${restic_ver}/restic-${restic_ver}.tar.gz \
&& tar -xzf /tmp/restic.tar.gz -C /tmp
# Backup performance patch.
RUN curl -fL -o /tmp/archiver.patch \
https://gist.githubusercontent.com/thiell/66de573550d161f1d7bae264ba4fdeb7/raw/e624e1451d4be637760b3f61d2245fc8ce68d558/archiver.go
# Build restic.
RUN cd /tmp/restic-* \
&& patch -p1 < /tmp/archiver.patch \
&& go run build.go \
&& cp restic /out/usr/local/bin/ \
&& cp LICENSE /out/usr/share/licenses/restic/
#
# Stage `runtime` creates final Docker image to use in runtime.
#
# https://hub.docker.com/_/alpine
FROM alpine:3.20 AS runtime
# Install restic runtime dependencies and upgrade existing packages.
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
ca-certificates \
fuse \
openssh \
rclone \
&& update-ca-certificates \
&& rm -rf /var/cache/apk/*
# Install restic.
COPY --from=dist /out/ /
# Prepare default restic env vars.
ENV RESTIC_REPOSITORY=/mnt/repo \
RESTIC_PASSWORD=""
VOLUME /data
ENTRYPOINT ["/usr/local/bin/restic"]