/
Dockerfile.compile
123 lines (102 loc) · 3.52 KB
/
Dockerfile.compile
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
FROM alpine:3.19 as go-builder
RUN apk add --no-cache go
WORKDIR /app
COPY build/dwk/* ./
RUN \
go mod download; \
CGO_ENABLED=0 GOOS=linux go build -o ./dwk
FROM alpine:3.16 as builder
ARG LIBTORRENT_TAG
ARG QBITTORRENT_TAG
ARG BUILD_DATE
WORKDIR /root/
# Install build dependencies
RUN \
apk update && \
apk add --no-cache --virtual .build-deps autoconf automake build-base cmake curl git libtool linux-headers perl pkgconf python3 python3-dev re2c tar \
icu-dev libexecinfo-dev openssl-dev qt5-qtbase-dev qt5-qttools-dev zlib-dev qt5-qtsvg-dev ninja boost-dev
# Compile Libtorrent
RUN \
git clone --shallow-submodules --recurse-submodules https://github.com/arvidn/libtorrent.git libtorrent && cd libtorrent && \
git checkout "${LIBTORRENT_TAG:-$(git tag -l --sort=-v:refname "v2*" | head -n 1)}" && \
cmake -Wno-dev -G Ninja -B build \
-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_CXX_STANDARD=17 \
-D CMAKE_INSTALL_LIBDIR="lib" \
-D CMAKE_INSTALL_PREFIX="/usr/local" && \
nice -n19 cmake --build build && \
cmake --install build
# Compile qBittorrent
RUN \
git clone --shallow-submodules --recurse-submodules https://github.com/qbittorrent/qBittorrent.git qbittorrent && cd qbittorrent && \
git checkout "${QBITTORRENT_TAG:-$(git tag -l --sort=-v:refname "release*" | head -n 1)}" && \
cmake -Wno-dev -G Ninja -B build \
-D CMAKE_BUILD_TYPE="release" \
-D CMAKE_CXX_STANDARD=17 \
-D CMAKE_CXX_STANDARD_LIBRARIES="/usr/lib/libexecinfo.so" \
-D CMAKE_INSTALL_PREFIX="/usr/local" \
-D GUI=OFF && \
nice -n19 cmake --build build
FROM alpine:3.19
# You can find the available release tags at https://github.com/just-containers/s6-overlay/releases
ARG S6_OVERLAY_TAG="v2.2.0.3"
# Exit if one of the cont-init.d scripts fails
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
RUN \
# Install tools
apk update && \
apk add --no-cache \
bash \
bind-tools \
dos2unix \
grep \
ipcalc \
iptables \
iputils \
net-tools \
nftables \
openresolv \
openssl \
openvpn \
procps \
qt5-qtbase \
sed \
tzdata \
wget; \
apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \
wireguard-go
COPY ./build/build-scripts /tmp/build-scripts
RUN \
# Install s6-overlay
wget https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_TAG}/s6-overlay-$(/bin/sh /tmp/build-scripts/s6-overlay-arch).tar.gz -O /tmp/s6_overlay.tar.gz && \
tar -xf /tmp/s6_overlay.tar.gz -C / && \
rm -r /tmp/*
RUN \
# Mount files from build stage
--mount=type=bind,from=builder,src=/root,dst=/mnt/build/ \
# Copy build files from ro mount
cp -r /mnt/build/libtorrent /root/ && \
cp -r /mnt/build/qbittorrent /root/ && \
# Add cmake
apk add --no-cache cmake && \
# Install libtorrent
cd /root/libtorrent && \
cmake --install build && \
# Install qBittorrent
cd /root/qbittorrent && \
cmake --install build && \
# Remove cmake
apk del --no-cache --purge cmake && \
# Remove build files
rm -r /root/qbittorrent /root/libtorrent
COPY rootfs /
RUN \
# Add go binaries from go-builder stage
--mount=type=bind,from=go-builder,src=/app/,dst=/mnt/go-builder/ \
cp /mnt/go-builder/dwk /helper/dwk
RUN \
# Set exec permissions
chmod +x -R /helper/ /etc/cont-init.d/ /etc/services.d/
VOLUME /config /downloads
EXPOSE 8080
CMD ["/init"]