Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
179 lines (155 loc) · 9.47 KB
/
Copy pathDockerfile
File metadata and controls
179 lines (155 loc) · 9.47 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Multi-architecture Dockerfile for Archiver
# Supports: linux/amd64, linux/arm64
# The Go CLI cross-compiles on the build platform, so an arm64 image is not built under
# emulation. Pure Go with CGO off: the binary needs nothing from the runtime image.
FROM --platform=$BUILDPLATFORM golang:1.27.4-trixie@sha256:f18c3d73a184fb0582828510722e723b63a93f7188d11dd223d9be6f6880e65d AS cli
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
# CI points this at the NAS artifact cache; the default keeps the image buildable anywhere.
ARG GOPROXY=https://proxy.golang.org,direct
COPY go.mod go.sum ./
COPY cmd/ ./cmd/
COPY internal/ ./internal/
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags='-s -w' -o /out/archiver ./cmd/archiver
# Duplicacy is built from its pinned source with the patches in build/duplicacy/ (ADR 26), in
# the order its series file gives; each patch says at its top what it changes, why, and which
# test proves it, and those tests run here. The CLI still runs as a child process.
FROM --platform=$BUILDPLATFORM golang:1.27.4-trixie@sha256:f18c3d73a184fb0582828510722e723b63a93f7188d11dd223d9be6f6880e65d AS duplicacy
ARG TARGETOS
ARG TARGETARCH
ARG GOPROXY=https://proxy.golang.org,direct
ARG DEBIAN_MIRROR=http://deb.debian.org
ARG GITHUB_MIRROR=https://github.com
# renovate: datasource=github-releases depName=gilbertchen/duplicacy extractVersion=^v(?<version>.+)$
ENV DUPLICACY_VERSION=3.3.0
ARG DUPLICACY_SOURCE_SHA256=dea27ecb17218e7df5bb8cb72f3f916934f2e2d2acdd6fe9a57991cebb53b38b
COPY build/duplicacy/ /patches/
RUN { sed -i "s#http://deb.debian.org#${DEBIAN_MIRROR}#g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true; } && \
apt-get update && apt-get install -y --no-install-recommends patch && \
curl -fsSL --retry 5 --retry-delay 3 --retry-all-errors --connect-timeout 15 --max-time 300 \
"${GITHUB_MIRROR}/gilbertchen/duplicacy/archive/refs/tags/v${DUPLICACY_VERSION}.tar.gz" -o /tmp/duplicacy.tar.gz && \
echo "$DUPLICACY_SOURCE_SHA256 /tmp/duplicacy.tar.gz" | sha256sum -c - && \
mkdir /src && tar -xzf /tmp/duplicacy.tar.gz -C /src --strip-components=1 && \
cd /src && series=$(grep -v '^#' /patches/series) && \
for p in $series; do grep -q '^+++ b/vendor/' "/patches/$p" || patch -p1 < "/patches/$p" || exit 1; done && \
go mod vendor && \
for p in $series; do ! grep -q '^+++ b/vendor/' "/patches/$p" || patch -p1 < "/patches/$p" || exit 1; done && \
tests=$(cd /patches && sed -n 's/^Test: \(Test[A-Za-z0-9_]*\)$/\1/p' $series | paste -sd'|') && \
{ go test -count=1 -vet=off -v -run "^($tests)\$" ./src/ > /tmp/patch-tests.out 2>&1 || { cat /tmp/patch-tests.out; exit 1; }; } && \
grep '^--- ' /tmp/patch-tests.out && \
[ "$(grep -c '^--- PASS' /tmp/patch-tests.out)" -eq "$(echo "$tests" | tr '|' '\n' | grep -c .)" ] && \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags='-s -w' -o /out/duplicacy ./duplicacy
# rclone places the recovery kit on every storage type (ADR 24). Its release is a zip, so a
# throwaway stage unpacks it and only the binary reaches the image.
FROM debian:trixie-20261104-slim@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2 AS rclone
ARG TARGETARCH
ARG DEBIAN_MIRROR=http://deb.debian.org
ARG GITHUB_MIRROR=https://github.com
# renovate: datasource=github-releases depName=rclone/rclone extractVersion=^v(?<version>.+)$
ENV RCLONE_VERSION=1.76.0
ARG RCLONE_SHA256_AMD64=b00f00b3266c3764413afe599d3ec316f6f43b3e0ea8a0bc1d186d2133e46df7
ARG RCLONE_SHA256_ARM64=ee169016675e23a69d77240565133ff7dbc9b33d16fa8f7053d4af39f1eaeb78
RUN { sed -i "s#http://deb.debian.org#${DEBIAN_MIRROR}#g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true; } && \
apt-get update && apt-get install -y --no-install-recommends curl ca-certificates unzip && \
if [ "$TARGETARCH" = "amd64" ]; then SHA256="$RCLONE_SHA256_AMD64"; \
elif [ "$TARGETARCH" = "arm64" ]; then SHA256="$RCLONE_SHA256_ARM64"; \
else echo "Unsupported architecture: $TARGETARCH" && exit 1; fi && \
curl -fsSL --retry 5 --retry-delay 3 --retry-all-errors --connect-timeout 15 --max-time 300 \
"${GITHUB_MIRROR}/rclone/rclone/releases/download/v${RCLONE_VERSION}/rclone-v${RCLONE_VERSION}-linux-${TARGETARCH}.zip" -o /tmp/rclone.zip && \
echo "$SHA256 /tmp/rclone.zip" | sha256sum -c - && \
unzip -j /tmp/rclone.zip "*/rclone" -d /out && chmod 755 /out/rclone
# The slim image (ADR 41): everything Archiver itself runs, and nothing only hooks use.
# The full image below adds those tools, and is the default target.
FROM debian:trixie-20261104-slim@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2 AS slim
ARG TARGETARCH
ARG DEBIAN_MIRROR=http://deb.debian.org
RUN { sed -i "s#http://deb.debian.org#${DEBIAN_MIRROR}#g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true; } && \
apt-get update && apt-get install -y --no-install-recommends \
tini \
openssh-client \
openssl \
curl \
ca-certificates \
tzdata \
qrencode \
&& { sed -i "s#${DEBIAN_MIRROR}#http://deb.debian.org#g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true; } \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/archiver
COPY lib/logos/ ./lib/logos/
COPY lib/host/archiver ./host/archiver
COPY docs/examples/ ./examples/
RUN mkdir -p /opt/archiver/logs /opt/archiver/keys
COPY --from=cli /out/archiver /usr/local/bin/archiver
COPY --from=rclone /out/rclone /usr/local/bin/rclone
COPY --from=duplicacy /out/duplicacy /usr/local/bin/duplicacy
# Hooks are executables (ADR 20); the e2e harness reads this to write them in that form.
LABEL io.archiver.hooks="executable"
ENV BACKUP_SCHEDULE=""
# Volumes
# /opt/archiver/logs - Optional: persistent logs directory
# User must also mount their service directories to backup
# /opt/archiver/bundle is deliberately NOT declared: Compose carries the previous
# container's mount over for image-declared volume paths on recreate, so a deployment that
# converted from a bundle would inherit the old bundle mount and refuse to start.
VOLUME ["/opt/archiver/logs"]
# Health check: Use archiver's built-in healthcheck command
# Runs comprehensive checks including config, keys, logs, and disk space
HEALTHCHECK --interval=5m --timeout=10s --start-period=1m --retries=3 \
CMD archiver healthcheck >/dev/null 2>&1 || exit 1
# tini is PID 1: it reaps processes orphaned by hooks (a Go PID 1 would not) and passes
# docker stop's SIGTERM to the entrypoint, which stops everything gracefully.
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/archiver", "entrypoint"]
CMD []
# The full image: the slim one plus the tools hooks use (docker, systemctl, zfs, btrfs,
# python3 with lmdb, sqlite3, an editor, ping, ps), so a hook needs no helper container.
FROM slim AS full
ARG TARGETARCH
ARG DEBIAN_MIRROR=http://deb.debian.org
RUN echo "deb http://deb.debian.org/debian trixie contrib" >> /etc/apt/sources.list.d/contrib.list && \
{ sed -i "s#http://deb.debian.org#${DEBIAN_MIRROR}#g" /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/contrib.list 2>/dev/null || true; } && \
apt-get update && apt-get install -y \
sqlite3 \
procps \
nano \
vim \
iputils-ping \
systemd \
zfsutils-linux \
btrfs-progs \
python3 \
python3-lmdb \
&& { sed -i "s#${DEBIAN_MIRROR}#http://deb.debian.org#g" /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/contrib.list 2>/dev/null || true; } \
&& rm -rf /var/lib/apt/lists/*
# Every download below is checked against a pinned SHA-256 per architecture: HTTPS
# authenticates the host, not the artifact, so a moved tag or a replaced release asset
# would otherwise land in every image. A version bump must bring new digests with it, or
# the build fails closed (tests/lint/dockerfile-downloads.sh guards the pattern).
ARG GITHUB_MIRROR=https://github.com
# moby/moby's release tag pattern is `docker-vX.Y.Z`; client/api/* tags
# are filtered out by the extractVersion anchor. The static binary
# archive at download.docker.com/linux/static/stable/<arch>/docker-<v>.tgz
# is published shortly after each engine release, without checksums; these are the
# digests of the reviewed archives.
# renovate: datasource=github-releases depName=moby/moby extractVersion=^docker-v(?<version>.+)$
ENV DOCKER_CLI_VERSION=29.9.3
ARG DOCKER_CLI_SHA256_AMD64=3fb5d1f13014c18cc54945bc177c58a9056a482dada031e17d12cf2e6922c973
ARG DOCKER_CLI_SHA256_ARM64=1b27fd739378ef938401e81ce5afb73b7ad7432d4f598814a9ff5f826bb464d2
# Pull the docker CLI binary directly from Docker's static archive
# instead of installing the docker-ce-cli debian package. The apt path
# uses a Debian-package version (`5:29.x.y-1~debian.13~trixie`) which has
# no clean Renovate datasource; the static binary uses plain SemVer.
ARG DOCKER_DOWNLOAD_MIRROR=https://download.docker.com
RUN ARCH_SUFFIX="" && \
if [ "$TARGETARCH" = "amd64" ]; then \
ARCH_SUFFIX="x86_64"; SHA256="$DOCKER_CLI_SHA256_AMD64"; \
elif [ "$TARGETARCH" = "arm64" ]; then \
ARCH_SUFFIX="aarch64"; SHA256="$DOCKER_CLI_SHA256_ARM64"; \
else \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi && \
curl -fsSL --retry 5 --retry-delay 3 --retry-all-errors --connect-timeout 15 --max-time 300 "${DOCKER_DOWNLOAD_MIRROR}/linux/static/stable/${ARCH_SUFFIX}/docker-${DOCKER_CLI_VERSION}.tgz" \
-o /tmp/docker-cli.tgz && \
echo "$SHA256 /tmp/docker-cli.tgz" | sha256sum -c - && \
tar -xzC /usr/local/bin --strip-components=1 -f /tmp/docker-cli.tgz docker/docker && \
rm /tmp/docker-cli.tgz