-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathDockerfile
More file actions
244 lines (209 loc) · 7.56 KB
/
Dockerfile
File metadata and controls
244 lines (209 loc) · 7.56 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
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
# syntax=docker/dockerfile:1
ARG CARES_VERSION=1.34.6
ARG CURL_VERSION=8.19.0
ARG LIBTORRENT_VERSION=v0.16.10
ARG RTORRENT_VERSION=v0.16.10
ARG MKTORRENT_VERSION=v1.1
ARG RUTORRENT_VERSION=v5.3.1
ARG DUMPTORRENT_VERSION=v1.7.0
ARG ALPINE_VERSION=3.22
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-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-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/pobrn/mktorrent.git"
ARG MKTORRENT_VERSION
RUN git fetch origin "${MKTORRENT_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 composer:2 AS update-geoip2-rutorrent
WORKDIR /app
COPY geoip2-rutorrent/composer.json ./
RUN composer update --no-dev --no-interaction --no-progress --prefer-dist --classmap-authoritative
FROM scratch AS export-geoip2-rutorrent
COPY --from=update-geoip2-rutorrent /app/composer.json /composer.json
COPY --from=update-geoip2-rutorrent /app/composer.lock /composer.lock
COPY --from=update-geoip2-rutorrent /app/vendor /vendor
FROM composer:2 AS vendor-geoip2-rutorrent
WORKDIR /app
COPY geoip2-rutorrent/composer.json geoip2-rutorrent/composer.lock ./
RUN composer install --no-dev --no-interaction --no-progress --prefer-dist --classmap-authoritative
FROM src AS src-geoip2-rutorrent
COPY geoip2-rutorrent /src
COPY --from=vendor-geoip2-rutorrent /app/vendor /src/vendor
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-dumptorrent
RUN git init . && git remote add origin "https://github.com/tomcdj71/dumptorrent.git"
ARG DUMPTORRENT_VERSION
RUN git fetch origin "${DUMPTORRENT_VERSION}" && git checkout -q FETCH_HEAD
RUN sed -i '1i #include <sys/time.h>' src/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 \
libpsl-dev \
libsigc++3-dev \
libtool \
libxslt-dev \
linux-headers \
ncurses-dev \
nghttp2-dev \
openssl-dev \
pcre-dev \
php84-dev \
php84-pear \
tar \
tree \
xz \
zlib-dev
RUN ln -s /usr/bin/php84 /usr/bin/php \
&& ln -s /usr/bin/php-config84 /usr/bin/php-config
ENV DIST_PATH="/dist"
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/libtorrent
COPY --from=src-libtorrent /src .
RUN autoreconf -vfi
RUN ./configure --enable-aligned
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
COPY --from=src-rtorrent /src .
RUN autoreconf -vfi
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/dumptorrent
COPY --from=src-dumptorrent /src .
RUN cmake -B build/ -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -S .
RUN cmake --build build/ --config Release --parallel $(nproc)
RUN cp build/dumptorrent build/scrapec ${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 \
grep \
gzip \
libsigc++3 \
libstdc++ \
mediainfo \
ncurses \
nginx \
nginx-mod-http-dav-ext \
nginx-mod-http-geoip2 \
openssl \
php84 \
php84-bcmath \
php84-ctype \
php84-curl \
php84-dom \
php84-fileinfo \
php84-fpm \
php84-mbstring \
php84-openssl \
php84-posix \
php84-session \
php84-sockets \
php84-xml \
php84-zip \
python3 \
py3-pip \
shadow \
sox \
tar \
tzdata \
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 \
&& ln -s /usr/bin/php84 /usr/bin/php \
&& rm -rf /tmp/*
COPY rootfs /
VOLUME [ "/data", "/downloads", "/passwd" ]
ENTRYPOINT [ "/init" ]
HEALTHCHECK --interval=30s --timeout=20s --start-period=10s \
CMD /usr/local/bin/healthcheck