/
Dockerfile
271 lines (238 loc) · 7.99 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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# syntax=docker/dockerfile:1
ARG LIBSIG_VERSION=3.0.3
ARG CARES_VERSION=1.24.0
ARG CURL_VERSION=8.5.0
ARG XMLRPC_VERSION=01.58.00
ARG LIBTORRENT_VERSION=v0.13.8
ARG RTORRENT_VERSION=v0.9.8
ARG MKTORRENT_VERSION=v1.1
ARG GEOIP2_PHPEXT_VERSION=1.3.1
# v4.3.1
ARG RUTORRENT_VERSION=97b431479022ceb1cc81df6b7e234e606bd3e13c
ARG GEOIP2_RUTORRENT_VERSION=4ff2bde530bb8eef13af84e4413cedea97eda148
ARG ALPINE_VERSION=3.19
ARG ALPINE_S6_VERSION=${ALPINE_VERSION}-2.2.0.3
FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS src
RUN apk --update --no-cache add curl git tar tree xz
WORKDIR /src
FROM src AS src-libsig
ARG LIBSIG_VERSION
RUN curl -sSL "https://download.gnome.org/sources/libsigc%2B%2B/3.0/libsigc%2B%2B-${LIBSIG_VERSION}.tar.xz" | tar xJv --strip 1
FROM src AS src-cares
ARG CARES_VERSION
RUN curl -sSL "https://c-ares.org/download/c-ares-${CARES_VERSION}.tar.gz" | tar xz --strip 1
FROM src AS src-xmlrpc
RUN git init . && git remote add origin "https://github.com/crazy-max/xmlrpc-c.git"
ARG XMLRPC_VERSION
RUN git fetch origin "${XMLRPC_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-curl
ARG CURL_VERSION
RUN curl -sSL "https://curl.se/download/curl-${CURL_VERSION}.tar.gz" | tar xz --strip 1
FROM src AS src-libtorrent
RUN git init . && git remote add origin "https://github.com/rakshasa/libtorrent.git"
ARG LIBTORRENT_VERSION
RUN git fetch origin "${LIBTORRENT_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-rtorrent
RUN git init . && git remote add origin "https://github.com/rakshasa/rtorrent.git"
ARG RTORRENT_VERSION
RUN git fetch origin "${RTORRENT_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-mktorrent
RUN git init . && git remote add origin "https://github.com/esmil/mktorrent.git"
ARG MKTORRENT_VERSION
RUN git fetch origin "${MKTORRENT_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-geoip2-phpext
RUN git init . && git remote add origin "https://github.com/rlerdorf/geoip.git"
ARG GEOIP2_PHPEXT_VERSION
RUN git fetch origin "${GEOIP2_PHPEXT_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-rutorrent
RUN git init . && git remote add origin "https://github.com/Novik/ruTorrent.git"
ARG RUTORRENT_VERSION
RUN git fetch origin "${RUTORRENT_VERSION}" && git checkout -q FETCH_HEAD
RUN rm -rf .git* conf/users plugins/geoip share
FROM src AS src-geoip2-rutorrent
RUN git init . && git remote add origin "https://github.com/Micdu70/geoip2-rutorrent.git"
ARG GEOIP2_RUTORRENT_VERSION
RUN git fetch origin "${GEOIP2_RUTORRENT_VERSION}" && git checkout -q FETCH_HEAD
RUN rm -rf .git*
FROM src AS src-mmdb
RUN curl -SsOL "https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-City.mmdb" \
&& curl -SsOL "https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-Country.mmdb"
FROM crazymax/alpine-s6:${ALPINE_S6_VERSION} AS builder
RUN apk --update --no-cache add \
autoconf \
automake \
binutils \
brotli-dev \
build-base \
cppunit-dev \
cmake \
gd-dev \
geoip-dev \
libtool \
libxslt-dev \
linux-headers \
ncurses-dev \
nghttp2-dev \
openssl-dev \
patch \
pcre-dev \
php82-dev \
php82-pear \
tar \
tree \
udns-dev \
xz \
zlib-dev
ENV DIST_PATH="/dist"
WORKDIR /usr/local/src/libsig
COPY --from=src-libsig /src .
RUN ./configure
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/cares
COPY --from=src-cares /src .
RUN cmake . -D CARES_SHARED=ON -D CMAKE_BUILD_TYPE:STRING="Release" -D CMAKE_C_FLAGS_RELEASE:STRING="-O3 -flto=\"$(nproc)\" -pipe"
RUN cmake --build . --clean-first --parallel $(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/curl
COPY --from=src-curl /src .
RUN cmake . -D ENABLE_ARES=ON CURL_LTO=ON -D CURL_USE_OPENSSL=ON -D CURL_BROTLI=ON -D CURL_ZSTD=ON -D BUILD_SHARED_LIBS=ON -D CMAKE_BUILD_TYPE:STRING="Release" -D CMAKE_C_FLAGS_RELEASE:STRING="-O3 -flto=\"$(nproc)\" -pipe"
RUN cmake --build . --clean-first --parallel $(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/xmlrpc
COPY --from=src-xmlrpc /src .
RUN ./configure --disable-wininet-client --disable-libwww-client --disable-cplusplus
RUN make -j$(nproc) CFLAGS="-w -O3 -flto" CXXFLAGS="-w -O3 -flto"
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/libtorrent
COPY --from=src-libtorrent /src .
COPY /patches/libtorrent .
RUN patch -p1 < throttle-fix-0.13.8.patch \
&& patch -p1 < libtorrent-udns-0.13.8.patch \
&& patch -p1 < libtorrent-scanf-0.13.8.patch
RUN ./autogen.sh
RUN ./configure --with-posix-fallocate --enable-aligned
RUN make -j$(nproc) CXXFLAGS="-w -O3 -flto"
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/rtorrent
COPY --from=src-rtorrent /src .
COPY /patches/rtorrent .
RUN patch -p1 < lockfile-fix.patch \
&& patch -p1 < rtorrent-scrape.patch \
&& patch -p1 < scgi-fix.patch \
&& patch -p1 < session-file-fix.patch \
&& patch -p1 < xmlrpc-fix.patch \
&& patch -p1 < xmlrpc-logic-fix.patch \
&& patch -p1 < rtorrent-ml-cg-fix.patch \
&& patch -p1 < rtorrent-ml-cui-fix.patch \
&& patch -p1 < rtorrent-ml-dc-fix.patch
RUN ./autogen.sh
RUN ./configure --with-xmlrpc-c --with-ncurses
RUN make -j$(nproc) CXXFLAGS="-w -O3 -flto"
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/mktorrent
COPY --from=src-mktorrent /src .
RUN make -j$(nproc) CC=gcc CFLAGS="-w -O3 -flto"
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/geoip2-phpext
COPY --from=src-geoip2-phpext /src .
RUN <<EOT
set -e
phpize82
./configure
make
make install
EOT
RUN mkdir -p ${DIST_PATH}/usr/lib/php82/modules
RUN cp -f /usr/lib/php82/modules/geoip.so ${DIST_PATH}/usr/lib/php82/modules/
RUN tree ${DIST_PATH}
FROM crazymax/alpine-s6:${ALPINE_S6_VERSION}
COPY --from=builder /dist /
COPY --from=src-rutorrent --chown=nobody:nogroup /src /var/www/rutorrent
COPY --from=src-geoip2-rutorrent --chown=nobody:nogroup /src /var/www/rutorrent/plugins/geoip2
COPY --from=src-mmdb /src /var/mmdb
ENV PYTHONPATH="$PYTHONPATH:/var/www/rutorrent" \
S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
S6_KILL_GRACETIME="10000" \
TZ="UTC" \
PUID="1000" \
PGID="1000"
# increase rmem_max and wmem_max for rTorrent configuration
RUN echo "net.core.rmem_max = 67108864" >> /etc/sysctl.conf \
&& echo "net.core.wmem_max = 67108864" >> /etc/sysctl.conf \
&& sysctl -p
# unrar package is not available since alpine 3.15
RUN echo "@314 http://dl-cdn.alpinelinux.org/alpine/v3.14/main" >> /etc/apk/repositories \
&& apk --update --no-cache add unrar@314
RUN apk --update --no-cache add \
apache2-utils \
bash \
bind-tools \
binutils \
brotli \
ca-certificates \
coreutils \
cppunit-dev \
dhclient \
ffmpeg \
findutils \
geoip \
grep \
gzip \
libstdc++ \
mediainfo \
ncurses \
nginx \
nginx-mod-http-dav-ext \
nginx-mod-http-geoip2 \
openssl \
php82 \
php82-bcmath \
php82-ctype \
php82-curl \
php82-dom \
php82-fileinfo \
php82-fpm \
php82-mbstring \
php82-openssl \
php82-phar \
php82-posix \
php82-session \
php82-sockets \
php82-xml \
php82-zip \
python3 \
py3-pip \
shadow \
sox \
tar \
tzdata \
udns \
unzip \
util-linux \
zip \
&& pip3 install --upgrade --break-system-packages pip \
&& pip3 install --break-system-packages cfscrape cloudscraper \
&& addgroup -g ${PGID} rtorrent \
&& adduser -D -H -u ${PUID} -G rtorrent -s /bin/sh rtorrent \
&& curl --version \
&& rm -rf /tmp/*
COPY rootfs /
VOLUME [ "/data", "/downloads", "/passwd" ]
ENTRYPOINT [ "/init" ]
HEALTHCHECK --interval=30s --timeout=20s --start-period=10s \
CMD /usr/local/bin/healthcheck