-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
404 lines (361 loc) · 10.7 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
ARG ALPINE_S6_TAG=3.14-2.2.0.3
ARG RTORRENT_VERSION=0.9.8
ARG LIBTORRENT_VERSION=0.13.8
ARG XMLRPC_VERSION=01.58.00
ARG LIBSIG_VERSION=3.0.3
ARG CARES_VERSION=1.17.2
ARG CURL_VERSION=7.78.0
ARG MKTORRENT_VERSION=1.1
ARG RUTORRENT_VERSION=3.10
ARG RUTORRENT_REVISION=954479ffd00eb58ad14f9a667b3b9b1e108e80a2
ARG GEOIP2_PHPEXT_VERSION=1.1.1
ARG NGINX_VERSION=1.21.1
ARG NGINX_DAV_VERSION=3.0.0
ARG NGINX_UID=102
ARG NGINX_GID=102
FROM --platform=${BUILDPLATFORM:-linux/amd64} crazymax/alpine-s6:${ALPINE_S6_TAG} AS download
RUN apk --update --no-cache add curl git subversion tar tree xz
ARG XMLRPC_VERSION
WORKDIR /dist/xmlrpc-c
RUN svn checkout "http://svn.code.sf.net/p/xmlrpc-c/code/release_number/${XMLRPC_VERSION}/" .
ARG LIBSIG_VERSION
WORKDIR /dist/libsigc
RUN curl -SsOL "http://ftp.gnome.org/pub/GNOME/sources/libsigc++/3.0/libsigc++-${LIBSIG_VERSION}.tar.xz" \
&& unxz "libsigc++-${LIBSIG_VERSION}.tar.xz" \
&& tar -xf "libsigc++-${LIBSIG_VERSION}.tar" --strip 1 \
&& rm -f "libsigc++-${LIBSIG_VERSION}.tar.xz" "libsigc++-${LIBSIG_VERSION}.tar"
ARG CARES_VERSION
WORKDIR /dist/c-ares
RUN curl -sSL "https://c-ares.haxx.se/download/c-ares-${CARES_VERSION}.tar.gz" | tar xz --strip 1
ARG CURL_VERSION
WORKDIR /dist/curl
RUN curl -sSL "https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz" | tar xz --strip 1
ARG LIBTORRENT_VERSION
WORKDIR /dist/libtorrent
RUN git clone --branch v${LIBTORRENT_VERSION} "https://github.com/rakshasa/libtorrent.git" .
ARG RTORRENT_VERSION
WORKDIR /dist/rtorrent
RUN git clone --branch v${RTORRENT_VERSION} "https://github.com/rakshasa/rtorrent.git" .
ARG MKTORRENT_VERSION
WORKDIR /dist/mktorrent
RUN git clone --branch v${MKTORRENT_VERSION} "https://github.com/esmil/mktorrent.git" .
ARG RUTORRENT_REVISION
WORKDIR /dist/rutorrent
RUN git clone "https://github.com/Novik/ruTorrent.git" . \
&& git reset --hard $RUTORRENT_REVISION \
&& rm -rf .git* conf/users plugins/geoip share
WORKDIR /dist/geoip2-rutorrent
RUN git clone "https://github.com/Micdu70/geoip2-rutorrent" . \
&& rm -rf .git*
WORKDIR /dist/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"
ARG GEOIP2_PHPEXT_VERSION
WORKDIR /dist/geoip-ext
RUN curl -SsL "https://pecl.php.net/get/geoip-${GEOIP2_PHPEXT_VERSION}.tgz" -o "geoip.tgz"
ARG NGINX_VERSION
ARG NGINX_DAV_VERSION
WORKDIR /dist/nginx
RUN curl -sSL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" | tar xz --strip 1
RUN git clone --branch v${NGINX_DAV_VERSION} "https://github.com/arut/nginx-dav-ext-module.git" nginx-dav-ext
ARG ALPINE_S6_TAG
FROM crazymax/alpine-s6:${ALPINE_S6_TAG} AS builder
RUN apk --update --no-cache add \
autoconf \
automake \
binutils \
brotli-dev \
build-base \
cppunit-dev \
gd-dev \
geoip-dev \
libtool \
libxslt-dev \
linux-headers \
ncurses-dev \
nghttp2-dev \
openssl-dev \
pcre-dev \
php7-dev \
php7-pear \
tar \
tree \
xz \
zlib-dev
ENV DIST_PATH="/dist"
COPY --from=download /dist /tmp
WORKDIR /tmp/libsigc
RUN ./configure
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/c-ares
RUN ./configure
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/curl
RUN ./configure \
--enable-ares \
--enable-tls-srp \
--enable-gnu-tls \
--with-brotli \
--with-ssl \
--with-zlib
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/xmlrpc-c
RUN ./configure
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/libtorrent
RUN ./autogen.sh
RUN ./configure \
--with-posix-fallocate
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/rtorrent
RUN ./autogen.sh
RUN ./configure \
--with-xmlrpc-c \
--with-ncurses
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/mktorrent
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
ARG NGINX_UID
ARG NGINX_GID
WORKDIR /tmp/nginx
RUN addgroup -g ${NGINX_UID} -S nginx
RUN adduser -S -D -H -u ${NGINX_GID} -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx
RUN ./configure \
--prefix=/usr/lib/nginx \
--sbin-path=/sbin/nginx \
--pid-path=/var/pid/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/dev/stdout \
--error-log-path=/dev/stderr \
--pid-path=/var/pid/nginx.pid \
--user=nginx \
--group=nginx \
--with-file-aio \
--with-pcre-jit \
--with-threads \
--with-poll_module \
--with-select_module \
--with-stream_ssl_module \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_degradation_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-mail_ssl_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail=dynamic \
--with-stream=dynamic \
--with-http_geoip_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_xslt_module=dynamic \
--add-dynamic-module=./nginx-dav-ext
RUN make -j$(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
WORKDIR /tmp/geoip-ext
RUN pecl install geoip.tgz
RUN mkdir -p ${DIST_PATH}/usr/lib/php7/modules
RUN cp -f /usr/lib/php7/modules/geoip.so ${DIST_PATH}/usr/lib/php7/modules/
RUN tree ${DIST_PATH}
ARG ALPINE_S6_TAG
FROM crazymax/alpine-s6:${ALPINE_S6_TAG}
COPY --from=builder /dist /
COPY --from=download --chown=nobody:nogroup /dist/rutorrent /var/www/rutorrent
COPY --from=download --chown=nobody:nogroup /dist/geoip2-rutorrent /var/www/rutorrent/plugins/geoip2
COPY --from=download /dist/mmdb /var/mmdb
ENV PYTHONPATH="$PYTHONPATH:/var/www/rutorrent" \
S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \
TZ="UTC" \
PUID="1000" \
PGID="1000"
ARG NGINX_UID
ARG NGINX_GID
RUN apk --update --no-cache add \
apache2-utils \
bash \
bind-tools \
binutils \
brotli \
ca-certificates \
coreutils \
dhclient \
ffmpeg \
findutils \
geoip \
grep \
gzip \
libstdc++ \
mediainfo \
ncurses \
openssl \
pcre \
php7 \
php7-bcmath \
php7-cli \
php7-ctype \
php7-curl \
php7-fpm \
php7-json \
php7-mbstring \
php7-openssl \
php7-phar \
php7-posix \
php7-session \
php7-sockets \
php7-xml \
php7-zip \
php7-zlib \
python3 \
py3-pip \
shadow \
sox \
tar \
tzdata \
unrar \
unzip \
util-linux \
zip \
zlib \
&& ln -s /usr/lib/nginx/modules /etc/nginx/modules \
&& addgroup -g ${NGINX_UID} -S nginx \
&& adduser -S -D -H -u ${NGINX_GID} -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \
&& pip3 install --upgrade pip \
&& pip3 install cfscrape cloudscraper \
&& addgroup -g ${PGID} rtorrent \
&& adduser -D -H -u ${PUID} -G rtorrent -s /bin/sh rtorrent \
&& curl --version \
&& rm -rf /tmp/* /var/cache/apk/*
COPY rootfs /
# COPY from irssi
RUN apk add --no-cache \
ca-certificates \
perl-libwww
ENV HOME /copy/data
RUN set -eux; \
mkdir -p "$HOME/.irssi"; \
chown -R ${PUID}:${PGID} "$HOME"
ENV LANG C.UTF-8
ENV IRSSI_VERSION 1.2.3
RUN set -eux; \
\
apk add --no-cache --virtual .build-deps \
autoconf \
automake \
coreutils \
curl \
dpkg-dev dpkg \
gcc \
glib-dev \
gnupg \
libc-dev \
libssl1.1 \
libxml2-dev \
libtool \
lynx \
make \
ncurses-dev \
openssl \
openssl-dev \
perl-dev \
pkgconf \
tar \
unzip \
wget \
zlib \
screen \
nano; \
wget "https://github.com/irssi/irssi/releases/download/${IRSSI_VERSION}/irssi-${IRSSI_VERSION}.tar.xz" -O /tmp/irssi.tar.xz; \
wget "https://github.com/irssi/irssi/releases/download/${IRSSI_VERSION}/irssi-${IRSSI_VERSION}.tar.xz.asc" -O /tmp/irssi.tar.xz.asc; \
export GNUPGHOME="$(mktemp -d)";\
rm -rf "$GNUPGHOME" /tmp/irssi.tar.xz.asc; \
mkdir -p /usr/src/irssi; \
tar -xf /tmp/irssi.tar.xz -C /usr/src/irssi --strip-components 1; \
rm /tmp/irssi.tar.xz;
RUN cd /usr/src/irssi; \
./configure \
--build="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
--enable-true-color \
--with-bot \
--with-proxy \
--with-socks \
; \
make -j "$(nproc)"; \
make install;
RUN cd /; \
rm -rf /usr/src/irssi; \
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .irssi-rundeps $runDeps;
#Basic smoke test
RUN irssi --version; \
cd $HOME;
RUN curl -L http://cpanmin.us | perl - App::cpanminus; \
cpanm --force Archive::Zip Net::SSLeay HTML::Entities XML::LibXML Digest::SHA JSON JSON::XS Filesys::DfPortable Filesys::DiskSpace; \
\
mkdir -p /copy/data/.irssi/scripts/autorun; \
cd /copy/data/.irssi/scripts; \
curl -sL https://api.github.com/repos/Teles1/autodl-irssi/releases/latest | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | xargs wget --quiet -O autodl-irssi.zip; \
unzip -o autodl-irssi.zip; \
rm autodl-irssi.zip; \
cp autodl-irssi.pl autorun/; \
mkdir -p /copy/data/.autodl; \
touch /copy/data/.autodl/autodl.cfg; \
echo "[options]" > /copy/data/.autodl/autodl.cfg; \
echo "rt-address = /var/run/rtorrent/scgi.socket" >> /copy/data/.autodl/autodl.cfg; \
echo "gui-server-port = 51499" >> /copy/data/.autodl/autodl.cfg; \
echo "gui-server-password = password" >> /copy/data/.autodl/autodl.cfg;
# rutorrent plugin for autodl-irssi
RUN mkdir -p /copy/data/rutorrent/plugins/; \
apk add git; \
cd /copy/data/rutorrent/plugins/; \
git clone https://github.com/autodl-community/autodl-rutorrent.git autodl-irssi; \
cd autodl-irssi; \
cp _conf.php conf.php; \
sed -i 's|$autodlPort = 0;|$autodlPort = 51499;|g' conf.php; \
sed -i 's|$autodlPassword = "";|$autodlPassword = "password";|g' conf.php;
# cleanup
RUN usermod -d /data rtorrent; \
rm -rf /tmp/* /var/cache/apk/*
ENV PATH $PATH:/data/bin
WORKDIR /data
ENV HOME /data
VOLUME [ "/data", "/downloads", "/passwd" ]
ENTRYPOINT [ "/init" ]
HEALTHCHECK --interval=30s --timeout=20s --start-period=10s \
CMD /usr/local/bin/healthcheck