Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
198 lines (154 loc) · 4.66 KB
/
Copy pathDockerfile
File metadata and controls
198 lines (154 loc) · 4.66 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# syntax=docker/dockerfile:1
FROM debian:trixie-slim
ARG TARGETARCH
ARG VERSION_ARG="4.2.0"
ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND="noninteractive"
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
SHELL ["/bin/bash", "-c"]
RUN <<EOF
# Break on errors
set -Eeuo pipefail
# Install prerequisites
apt-get update
apt-get install -y --no-install-recommends \
bc \
jq \
curl \
tini \
nano \
wget \
htop \
less \
cpio \
dpkg \
gosu \
iotop \
gnupg \
procps \
locales \
rsyslog \
postfix \
iptables \
iproute2 \
ifupdown2 \
jfsutils \
xfsprogs \
e2fsprogs \
net-tools \
nfs-common \
cifs-utils \
traceroute \
open-iscsi \
btrfs-progs \
iputils-ping \
netcat-openbsd \
ca-certificates \
isc-dhcp-client
# Prevent services from starting during install
printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
# Block unneeded packages in container
cat >/etc/apt/preferences.d/99-pdm-unneeded-packages <<BLK
Package: proxmox-default-kernel proxmox-kernel-* pve-firmware
Pin: release *
Pin-Priority: -1
BLK
# Stub commands unavailable / problematic in a Docker build
dpkg-divert --local --rename --add /usr/bin/unshare
printf '#!/bin/sh\nwhile [ $# -gt 0 ] && [ "$1" != "--" ]; do shift; done\n[ "$1" = "--" ] && \
shift\n[ $# -gt 0 ] && exec "$@"\nexit 0\n' > /usr/bin/unshare
chmod +x /usr/bin/unshare
dpkg-divert --local --rename --add /usr/sbin/update-initramfs
printf '#!/bin/sh\nexit 0\n' > /usr/sbin/update-initramfs
chmod +x /usr/sbin/update-initramfs
dpkg-divert --local --rename --add /usr/sbin/ifreload
printf '#!/bin/sh\n[ "$1" = "-V" ] && printf "%%s\n" "ifupdown2:3.3.0-1+pmx12"\nexit 0\n' > /usr/sbin/ifreload
chmod +x /usr/sbin/ifreload
printf '#!/bin/sh\nexit 0\n' > /usr/local/sbin/systemctl
chmod +x /usr/local/sbin/systemctl
# Install Proxmox Backup Server
if [[ "$TARGETARCH" == "amd64" ]]; then
# Add Proxmox Backup Server repository
curl -sL https://enterprise.proxmox.com/debian/proxmox-archive-keyring-trixie.gpg \
-o /usr/share/keyrings/proxmox-archive-keyring.gpg
cat <<'DEB' | sed 's/^[[:space:]]*//' > /etc/apt/sources.list.d/pbs-no-subscription.sources
Types: deb
URIs: http://download.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
DEB
apt-get update
apt-get install -y --no-install-recommends \
proxmox-backup-docs \
proxmox-backup-client \
proxmox-backup-server
else
apt-get install -y --no-install-recommends \
git \
sudo \
dpkg-dev \
apt-transport-https
tmpdir="/tmp/deb"
rm -rf "$tmpdir"
mkdir -p "$tmpdir"
# Download packages from repo: qemus/proxmox-backup-arm64
git clone --depth 1 https://github.com/qemus/proxmox-backup-arm64.git "$tmpdir"
chmod +x "$tmpdir/build.sh"
(cd "$tmpdir" && ./build.sh "install=${VERSION_ARG}")
rm -rf "$tmpdir"
SUDO_FORCE_REMOVE=yes apt-get remove -y \
git \
sudo \
dpkg-dev \
apt-transport-https
fi
# Prevent system updates
apt-mark hold \
proxmox-backup-docs \
proxmox-backup-client \
proxmox-backup-server
# Install supercronic
if [[ "$TARGETARCH" == "amd64" ]]; then
SUPERCRONIC=supercronic-linux-amd64
SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.46/supercronic-linux-amd64
else
SUPERCRONIC=supercronic-linux-arm64
SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.46/supercronic-linux-arm64
fi
curl -fsSLO "$SUPERCRONIC_URL"
chmod +x "$SUPERCRONIC"
mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}"
ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
# Remove enterprise repo added by Proxmox packages — keep only no-subscription
rm -f /etc/apt/sources.list.d/pbs-enterprise.list \
/etc/apt/sources.list.d/pbs-enterprise.sources \
/etc/apt/sources.list.d/ceph.list \
/etc/apt/sources.list.d/ceph.sources
# Cleanup
apt-get autoremove -y
apt-get clean
# Generate locales
locale-gen en_US.UTF-8
# Set username and password
echo "root:root" | chpasswd
# Redirect rsyslog
sed -i '/.*imklog.*/d' /etc/rsyslog.conf && \
echo '*.* -/proc/1/fd/1' >> /etc/rsyslog.conf
# Store version number
echo "$VERSION_ARG" > /etc/version
# Remove stub
rm /usr/local/sbin/systemctl
# Cleanup files
rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/*
EOF
WORKDIR /usr/local/bin
COPY --chmod=755 ./src /usr/local/bin/
ENV PASSWORD="root"
EXPOSE 8007
VOLUME /etc/proxmox-backup
VOLUME /var/lib/proxmox-backup
HEALTHCHECK --interval=60s --timeout=10s --start-period=60s --retries=3 \
CMD ["curl", "-kLfSs", "https://localhost:8007/"]
ENTRYPOINT ["/usr/bin/tini", "-s", "/usr/local/bin/entrypoint.sh"]