forked from itzg/docker-mc-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (60 loc) · 2.69 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FROM alpine AS builder
# provided by buildx when using --platform
# or manually using --build-arg TARGETARCH=amd64 --build-arg TARGETVARIANT=
ARG TARGETARCH
ARG TARGETVARIANT
RUN mkdir -p /opt
ARG RCON_CLI_VERSION=1.6.0
ADD https://github.com/itzg/rcon-cli/releases/download/${RCON_CLI_VERSION}/rcon-cli_${RCON_CLI_VERSION}_linux_${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/rcon-cli.tar.gz
RUN tar x -f /tmp/rcon-cli.tar.gz -C /opt/ && \
chmod +x /opt/rcon-cli
ARG MC_MONITOR_VERSION=0.10.6
ADD https://github.com/itzg/mc-monitor/releases/download/${MC_MONITOR_VERSION}/mc-monitor_${MC_MONITOR_VERSION}_linux_${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/mc-monitor.tar.gz
RUN tar x -f /tmp/mc-monitor.tar.gz -C /opt/ && \
chmod +x /opt/mc-monitor
ARG RESTIC_VERSION=0.14.0
# NOTE: restic releases don't differentiate arm v6 from v7, so TARGETVARIANT is not used
# and have to assume they release armv7
ADD https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_${TARGETARCH}.bz2 /tmp/restic.bz2
RUN bunzip2 /tmp/restic.bz2 && \
mv /tmp/restic /opt/restic && \
chmod +x /opt/restic
ARG DEMOTER_VERSION=0.4.0
ADD https://github.com/itzg/entrypoint-demoter/releases/download/v${DEMOTER_VERSION}/entrypoint-demoter_${DEMOTER_VERSION}_Linux_${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/entrypoint-demoter.tar.gz
RUN tar x -f /tmp/entrypoint-demoter.tar.gz -C /opt/ && \
chmod +x /opt/entrypoint-demoter
ARG RCLONE_VERSION=1.59.2
ADD https://downloads.rclone.org/v${RCLONE_VERSION}/rclone-v${RCLONE_VERSION}-linux-${TARGETARCH}.zip /tmp/rclone.zip
RUN mkdir -p /tmp/rclone && \
unzip /tmp/rclone.zip -d /tmp/rclone && \
mv /tmp/rclone/rclone-v${RCLONE_VERSION}-linux-${TARGETARCH}/rclone /opt/rclone && \
chmod +x /opt/rclone
FROM alpine
RUN apk -U --no-cache add \
bash \
coreutils \
openssh-client \
tar \
tzdata \
zstd
COPY --from=builder /opt/rcon-cli /opt/rcon-cli
RUN ln -s /opt/rcon-cli /usr/bin
COPY --from=builder /opt/mc-monitor /opt/mc-monitor
RUN ln -s /opt/mc-monitor /usr/bin
COPY --from=builder /opt/restic /opt/restic
RUN ln -s /opt/restic /usr/bin
COPY --from=builder /opt/entrypoint-demoter /opt/entrypoint-demoter
RUN ln -s /opt/entrypoint-demoter /usr/bin
COPY --from=builder /opt/rclone /opt/rclone
RUN ln -s /opt/rclone /usr/bin
COPY backup-loop.sh /opt/
COPY backup /usr/bin/
RUN chmod +x /opt/backup-loop.sh /usr/bin/backup
VOLUME ["/data", "/backups"]
WORKDIR "/backups"
# Workaround for some tools (i.e. RCLONE) creating cache files in $HOME
# and not having permissions to write when demoter does demote to UID,
# while keeping the $HOME=/root
ENV HOME=/tmp
ENTRYPOINT ["/usr/bin/backup"]
CMD ["loop"]