-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathDockerfile
257 lines (223 loc) · 7.72 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
# syntax=docker/dockerfile:1
ARG LIBSIG_VERSION=3.0.3
ARG CARES_VERSION=1.34.4
ARG CURL_VERSION=8.11.1
ARG MKTORRENT_VERSION=v1.1
ARG GEOIP2_PHPEXT_VERSION=1.3.1
# v5.1.5
ARG RUTORRENT_VERSION=25679a45a1e2ca9f7a9e01cab5cc554b8eaa7230
ARG GEOIP2_RUTORRENT_VERSION=4ff2bde530bb8eef13af84e4413cedea97eda148
ARG DUMP_TORRENT_VERSION=302ac444a20442edb4aeabef65b264a85ab88ce9
# v7.2-0.9.8-0.13.8
ARG RTORRENT_STICKZ_VERSION=2f99fa971d65aabc14a367ef077be58cd859bc79
ARG ALPINE_VERSION=3.21
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 sed 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://github.com/c-ares/c-ares/releases/download/v${CARES_VERSION}/c-ares-${CARES_VERSION}.tar.gz" | tar xz --strip 1
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-rtorrent
RUN git init . && git remote add origin "https://github.com/stickz/rtorrent.git"
ARG RTORRENT_STICKZ_VERSION
RUN git fetch origin "${RTORRENT_STICKZ_VERSION}" && git checkout -q FETCH_HEAD
FROM src AS src-mktorrent
RUN git init . && git remote add origin "https://github.com/pobrn/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 src AS src-dump-torrent
RUN git init . && git remote add origin "https://github.com/TheGoblinHero/dumptorrent.git"
ARG DUMP_TORRENT_VERSION
RUN git fetch origin "${DUMP_TORRENT_VERSION}" && git checkout -q FETCH_HEAD
RUN sed -i '1i #include <sys/time.h>' scrapec.c
RUN rm -rf .git*
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 \
pcre-dev \
php83-dev \
php83-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 -D 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/rtorrent
COPY --from=src-rtorrent /src .
WORKDIR /usr/local/src/rtorrent/libtorrent
RUN ./autogen.sh
RUN ./configure --enable-aligned --disable-instrumentation --enable-udns
RUN make -j$(nproc) CXXFLAGS="-w -O3 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/rtorrent/rtorrent
RUN ./autogen.sh
RUN ./configure --with-xmlrpc-tinyxml2 --with-ncurses
RUN make -j$(nproc) CXXFLAGS="-w -O3 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
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 echo "CC = gcc" >> Makefile
RUN echo "CFLAGS = -w -flto -O3" >> Makefile
RUN echo "USE_PTHREADS = 1" >> Makefile
RUN echo "USE_OPENSSL = 1" >> Makefile
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/geoip2-phpext
COPY --from=src-geoip2-phpext /src .
RUN <<EOT
set -e
phpize83
./configure
make
make install
EOT
RUN mkdir -p ${DIST_PATH}/usr/lib/php83/modules
RUN cp -f /usr/lib/php83/modules/geoip.so ${DIST_PATH}/usr/lib/php83/modules/
RUN tree ${DIST_PATH}
WORKDIR /usr/local/src/dump-torrent
COPY --from=src-dump-torrent /src .
RUN make dumptorrent -j$(nproc)
RUN cp dumptorrent ${DIST_PATH}/usr/local/bin
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
# dhclient package is not available since alpine 3.21
RUN echo "@314 http://dl-cdn.alpinelinux.org/alpine/v3.14/main" >> /etc/apk/repositories \
&& echo "@320 http://dl-cdn.alpinelinux.org/alpine/v3.20/main" >> /etc/apk/repositories \
&& apk --update --no-cache add unrar@314 dhclient@320
RUN apk --update --no-cache add \
apache2-utils \
bash \
bind-tools \
binutils \
brotli \
ca-certificates \
coreutils \
ffmpeg \
findutils \
geoip \
grep \
gzip \
libstdc++ \
mediainfo \
ncurses \
nginx \
nginx-mod-http-dav-ext \
nginx-mod-http-geoip2 \
openssl \
php83 \
php83-bcmath \
php83-ctype \
php83-curl \
php83-dom \
php83-fileinfo \
php83-fpm \
php83-mbstring \
php83-openssl \
php83-phar \
php83-posix \
php83-session \
php83-sockets \
php83-xml \
php83-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