From 07272dd296da09f0809a2cf9322f6b7b42a2cd5e Mon Sep 17 00:00:00 2001 From: stickz Date: Tue, 19 Nov 2024 10:26:28 -0500 Subject: [PATCH] mktorrent: Build with pthreads This pull request builds and installs mktorrent with pthreads. The speed improvement is up to 8 times for creating torrents from ruTorrent. It creates a separate src image that will be used to download more source code in future pull requests. --- Dockerfile | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 070f2c0..c9b42fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,19 @@ -FROM alpine:3.20 AS builder - +ARG MKTORRENT_VERSION=v1.1 ARG UNRAR_VER=7.0.9 +# Create src image to retreive source files +FROM alpine:3.20 AS src +RUN apk --update --no-cache add curl git tar tree xz +WORKDIR /src + +# 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 + +FROM alpine:3.20 AS builder + RUN apk --update --no-cache add \ autoconf \ automake \ @@ -21,6 +33,16 @@ RUN apk --update --no-cache add \ && make -f makefile \ && install -Dm 755 unrar /usr/bin/unrar +# 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) + FROM alpine:3.20 LABEL description="rutorrent based on alpinelinux" \ @@ -59,7 +81,6 @@ RUN apk --update --no-cache add \ libzen \ libzen-dev \ mediainfo \ - mktorrent \ nginx \ openssl \ php82 \