From b9f6f1c6167d555502bd6444245898c7ea3cdc5d Mon Sep 17 00:00:00 2001 From: bobpaul <90864+bobpaul@users.noreply.github.com> Date: Tue, 4 Feb 2025 20:57:36 -0500 Subject: [PATCH 1/5] Removed dependency on unmaintained docker container --- Dockerfile | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3fb9be5792..950baa299f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,3 @@ -# Need this image for the /bin/start-build script. -# Build unrar. It has been moved to non-free since Alpine 3.15. -# https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.15.0#unrar_moved_to_non-free -FROM jlesage/alpine-abuild:3.15 AS unrar -WORKDIR /tmp -RUN \ - mkdir /tmp/aport && \ - cd /tmp/aport && \ - git init && \ - git remote add origin https://github.com/alpinelinux/aports && \ - git config core.sparsecheckout true && \ - echo "non-free/unrar/*" >> .git/info/sparse-checkout && \ - git pull origin 3.15-stable && \ - PKG_SRC_DIR=/tmp/aport/non-free/unrar && \ - PKG_DST_DIR=/tmp/unrar-pkg && \ - mkdir "$PKG_DST_DIR" && \ - /bin/start-build -r && \ - rm /tmp/unrar-pkg/*-doc-* && \ - mkdir /tmp/unrar-install && \ - tar xf /tmp/unrar-pkg/unrar-*.apk -C /tmp/unrar-install - FROM python:3.10.8-alpine3.15 LABEL maintainer="pymedusa" @@ -30,6 +9,34 @@ ENV MEDUSA_COMMIT_HASH $GIT_COMMIT ARG BUILD_DATE LABEL build_version="Branch: $GIT_BRANCH | Commit: $GIT_COMMIT | Build-Date: $BUILD_DATE" +ARG UNRAR_VERSION=7.0.9 +# Build unrar +RUN \ + echo "**** install build dependencies ****" && \ + apk add --no-cache --virtual=build-dependencies \ + build-base \ + curl \ + linux-headers && \ + echo "**** install unrar from source ****" && \ + mkdir /tmp/unrar && \ + curl -o \ + /tmp/unrar.tar.gz -L \ + "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \ + tar xf \ + /tmp/unrar.tar.gz -C \ + /tmp/unrar --strip-components=1 && \ + cd /tmp/unrar && \ + sed -i 's|LDFLAGS=-pthread|LDFLAGS=-pthread -static|' makefile && \ + sed -i 's|CXXFLAGS=-march=native|CXXFLAGS=-mcpu=power8|' makefile && \ + make && \ + install -v -m755 unrar /usr/bin && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /root/.cache \ + /tmp/* + # Install packages RUN \ # Update @@ -49,9 +56,6 @@ RUN \ # Install app COPY . /app/medusa/ -# Copy unrar bin -COPY --from=unrar /tmp/unrar-install/usr/bin/unrar /usr/bin/ - # Ports and Volumes EXPOSE 8081 VOLUME /config /downloads /tv /anime From cf58262bee5abdc194ea56d5d1cc93cf16ffe657 Mon Sep 17 00:00:00 2001 From: bobpaul <90864+bobpaul@users.noreply.github.com> Date: Tue, 11 Feb 2025 00:14:01 -0500 Subject: [PATCH 2/5] Set CXXFLAGs based on architecture of docker image --- Dockerfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 950baa299f..9f64e40032 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10.8-alpine3.15 +FROM --platform=${TARGETPLATFORM} python:3.10.8-alpine3.15 LABEL maintainer="pymedusa" ARG GIT_BRANCH @@ -6,9 +6,11 @@ ARG GIT_COMMIT ENV MEDUSA_COMMIT_BRANCH $GIT_BRANCH ENV MEDUSA_COMMIT_HASH $GIT_COMMIT +ARG TARGETARCH ARG BUILD_DATE LABEL build_version="Branch: $GIT_BRANCH | Commit: $GIT_COMMIT | Build-Date: $BUILD_DATE" +ARG CXXFLAGS ARG UNRAR_VERSION=7.0.9 # Build unrar RUN \ @@ -27,7 +29,14 @@ RUN \ /tmp/unrar --strip-components=1 && \ cd /tmp/unrar && \ sed -i 's|LDFLAGS=-pthread|LDFLAGS=-pthread -static|' makefile && \ - sed -i 's|CXXFLAGS=-march=native|CXXFLAGS=-mcpu=power8|' makefile && \ + if [ -z $CXXFLAGS ]; then \ + if [ "$TARGETARCH"x == "amd64"x ]; then \ + CXXFLAGS='-march=x86-64'; \ + elif [ "$TARGETARCH"x == "arm64"x ]; then \ + CXXFLAGS='-march=armv8-a+crypto+crc'; \ + fi \ + fi && \ + sed -i "s|CXXFLAGS=-march=native|CXXFLAGS=$CXXFLAGS|" makefile && \ make && \ install -v -m755 unrar /usr/bin && \ echo "**** cleanup ****" && \ From 8fcf972680b112792cc9cb8e82ee1c5e38dd922a Mon Sep 17 00:00:00 2001 From: bobpaul <90864+bobpaul@users.noreply.github.com> Date: Tue, 11 Feb 2025 02:06:32 -0500 Subject: [PATCH 3/5] Added CXFLAGS for ARMv7 --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9f64e40032..9df9dcf488 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,8 @@ RUN \ CXXFLAGS='-march=x86-64'; \ elif [ "$TARGETARCH"x == "arm64"x ]; then \ CXXFLAGS='-march=armv8-a+crypto+crc'; \ + elif [ "$TARGETARCH"x == "arm"x ]; then \ + CXXFLAGS='-march=armv7-a -mfloat-abi=hard -mfpu=neon'; \ fi \ fi && \ sed -i "s|CXXFLAGS=-march=native|CXXFLAGS=$CXXFLAGS|" makefile && \ From 0695438a1441a4ed2364153f27589d5b3678e892 Mon Sep 17 00:00:00 2001 From: bobpaul <90864+bobpaul@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:41:48 -0500 Subject: [PATCH 4/5] Split to 2 stage build for build cache --- Dockerfile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9df9dcf488..d71abbb265 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,10 @@ -FROM --platform=${TARGETPLATFORM} python:3.10.8-alpine3.15 -LABEL maintainer="pymedusa" - -ARG GIT_BRANCH -ARG GIT_COMMIT -ENV MEDUSA_COMMIT_BRANCH $GIT_BRANCH -ENV MEDUSA_COMMIT_HASH $GIT_COMMIT +FROM python:3.10.16-alpine3.21 AS builder ARG TARGETARCH -ARG BUILD_DATE -LABEL build_version="Branch: $GIT_BRANCH | Commit: $GIT_COMMIT | Build-Date: $BUILD_DATE" - ARG CXXFLAGS ARG UNRAR_VERSION=7.0.9 # Build unrar +WORKDIR /unrar RUN \ echo "**** install build dependencies ****" && \ apk add --no-cache --virtual=build-dependencies \ @@ -26,8 +18,7 @@ RUN \ "https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" && \ tar xf \ /tmp/unrar.tar.gz -C \ - /tmp/unrar --strip-components=1 && \ - cd /tmp/unrar && \ + /unrar --strip-components=1 && \ sed -i 's|LDFLAGS=-pthread|LDFLAGS=-pthread -static|' makefile && \ if [ -z $CXXFLAGS ]; then \ if [ "$TARGETARCH"x == "amd64"x ]; then \ @@ -40,7 +31,6 @@ RUN \ fi && \ sed -i "s|CXXFLAGS=-march=native|CXXFLAGS=$CXXFLAGS|" makefile && \ make && \ - install -v -m755 unrar /usr/bin && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \ @@ -48,6 +38,18 @@ RUN \ /root/.cache \ /tmp/* +FROM python:3.10.16-alpine3.21 +LABEL maintainer="pymedusa" + +ARG GIT_BRANCH +ARG GIT_COMMIT +ENV MEDUSA_COMMIT_BRANCH $GIT_BRANCH +ENV MEDUSA_COMMIT_HASH $GIT_COMMIT + +ARG BUILD_DATE +LABEL build_version="Branch: $GIT_BRANCH | Commit: $GIT_COMMIT | Build-Date: $BUILD_DATE" + +COPY --from=builder /unrar/unrar /usr/bin # Install packages RUN \ # Update From 66e63119d78c3e68b396bf52648b7c8a81fbad1e Mon Sep 17 00:00:00 2001 From: bobpaul <90864+bobpaul@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:45:19 -0500 Subject: [PATCH 5/5] Support multicore compiling --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d71abbb265..85663a9abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM python:3.10.16-alpine3.21 AS builder ARG TARGETARCH ARG CXXFLAGS ARG UNRAR_VERSION=7.0.9 +# Use all cores to compile, set JOBS=1 to disable +ARG JOBS # Build unrar WORKDIR /unrar RUN \ @@ -30,7 +32,7 @@ RUN \ fi \ fi && \ sed -i "s|CXXFLAGS=-march=native|CXXFLAGS=$CXXFLAGS|" makefile && \ - make && \ + make -j ${JOBS} && \ echo "**** cleanup ****" && \ apk del --purge \ build-dependencies && \