-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
186 lines (164 loc) · 5.62 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
ARG CARES_VERSION=1.34.3
ARG CURL_VERSION=8.11.0
ARG MKTORRENT_VERSION=v1.1
ARG DUMP_TORRENT_VERSION=302ac444a20442edb4aeabef65b264a85ab88ce9
# Create src image to retreive source files
FROM alpine:3.21 AS src
RUN apk --update --no-cache add curl git tar sed tree xz
WORKDIR /src
# Retreive c-ares source files
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
# Retreive curl source files
FROM src AS src-curl
ARG CURL_VERSION
RUN curl -sSL "https://curl.se/download/curl-${CURL_VERSION}.tar.gz" | tar xz --strip 1
# Retreive source files for mktorrent
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
# Retreive source files for dumptorrent. Repair build for alpine Linux.
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 alpine:3.21 AS builder
ENV DIST_PATH="/dist"
RUN apk --update --no-cache add \
autoconf \
automake \
binutils \
brotli-dev \
build-base \
cmake \
cppunit-dev \
curl-dev \
libtool \
linux-headers \
openssl-dev \
tree \
zlib-dev
# Build and install c-ares for asynchronous DNS resolution of TCP trackers on rTorrent
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"
RUN cmake --build . --clean-first --parallel $(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
# Build and install curl with c-ares for asynchronous DNS resolution of TCP trackers on rTorrent
WORKDIR /usr/local/src/curl
COPY --from=src-curl /src .
RUN cmake . -D ENABLE_ARES=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"
RUN cmake --build . --clean-first --parallel $(nproc)
RUN make install -j$(nproc)
RUN make DESTDIR=${DIST_PATH} install -j$(nproc)
RUN tree ${DIST_PATH}
# Build and install mktorrent with pthreads
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}
# Build and install dump torrent for ruTorrent plugin
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 alpine:3.21
LABEL description="rutorrent based on alpinelinux" \
maintainer="magicalex <[email protected]>"
ARG FILEBOT=false
ARG FILEBOT_VER=5.1.6
ARG RUTORRENT_VER=5.1.2
ENV UID=991 \
GID=991 \
PORT_RTORRENT=45000 \
MODE_DHT=off \
PORT_DHT=6881 \
PEER_EXCHANGE=no \
DOWNLOAD_DIRECTORY=/data/downloads \
CHECK_PERM_DATA=true \
FILEBOT_RENAME_METHOD=symlink \
FILEBOT_LANG=fr \
FILEBOT_CONFLICT=skip \
HTTP_AUTH=false
COPY --from=builder /dist /
# 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 echo "@320 http://dl-cdn.alpinelinux.org/alpine/v3.20/main" >> /etc/apk/repositories \
&& apk --update --no-cache add s6@320
RUN apk --update --no-cache add \
7zip \
bash \
ffmpeg \
ffmpeg-dev \
findutils \
git \
libmediainfo \
libmediainfo-dev \
libzen \
libzen-dev \
mediainfo \
nginx \
openssl \
php82 \
php82-bcmath \
php82-ctype \
php82-curl \
php82-dom \
php82-fpm \
php82-mbstring \
php82-opcache \
php82-openssl \
php82-pecl-apcu \
php82-phar \
php82-session \
php82-sockets \
php82-xml \
php82-zip \
rtorrent \
sox \
su-exec \
unzip \
# Install rutorrent
&& git clone -b v${RUTORRENT_VER} --recurse-submodules https://github.com/Novik/ruTorrent.git /rutorrent/app \
&& git clone https://github.com/Micdu70/geoip2-rutorrent.git /rutorrent/app/plugins/geoip2 \
&& git clone https://github.com/Micdu70/rutorrent-ratiocolor.git /rutorrent/app/plugins/ratiocolor \
&& rm -rf /rutorrent/app/plugins/geoip \
&& rm -rf /rutorrent/app/plugins/_cloudflare \
&& rm -rf /rutorrent/app/plugins/geoip2/.git \
&& rm -rf /rutorrent/app/plugins/ratiocolor/.git \
&& rm -rf /rutorrent/app/.git \
# Socket folder
&& mkdir -p /run/rtorrent /run/nginx /run/php
RUN if [ "${FILEBOT}" = true ]; then \
apk --update --no-cache add \
chromaprint \
openjdk17-jre-headless \
# Install filebot
&& mkdir /filebot \
&& cd /filebot \
&& wget "https://get.filebot.net/filebot/FileBot_${FILEBOT_VER}/FileBot_${FILEBOT_VER}-portable.tar.xz" -O /filebot/filebot.tar.xz \
&& tar -xJf filebot.tar.xz \
&& rm -rf filebot.tar.xz \
&& sed -i 's/-Dapplication.deployment=tar/-Dapplication.deployment=docker/g' /filebot/filebot.sh \
&& find /filebot/lib -type f -not -name libjnidispatch.so -delete; \
fi
COPY rootfs /
RUN chmod 775 /usr/local/bin/*
VOLUME /data /config
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/startup"]
CMD ["/bin/s6-svscan", "/etc/s6.d"]