Build and install 7z.so, loading Codecs/Rar.so is broken

Also use multistage builds to have smaller images
This commit is contained in:
Luis Ángel San Martín 2024-09-22 15:20:30 +02:00
parent fc853630d8
commit f0c142b300
3 changed files with 59 additions and 38 deletions

View File

@ -129,22 +129,8 @@ QLibrary *YACReader::load7zLibrary()
auto yacreader7zPath = QString(LIBDIR) + "/yacreader/7z.so";
QFileInfo sevenzlibrary(yacreader7zPath);
if (sevenzlibrary.exists()) {
auto rarPath = QString(LIBDIR) + "/yacreader/Codecs/Rar.so";
QFileInfo rarCodec(rarPath);
if (rarCodec.exists()) {
QLibrary *rarLibrary = new QLibrary(rarPath);
rarLibrary->load();
}
return new QLibrary(yacreader7zPath);
} else {
auto rarPath = QString(LIBDIR) + "/7zip/Codecs/Rar.so";
QFileInfo rarCodec(rarPath);
if (rarCodec.exists()) {
QLibrary *rarLibrary = new QLibrary(rarPath);
rarLibrary->load();
}
return new QLibrary(QString(LIBDIR) + "/7zip/7z.so");
}
#else

View File

@ -1,4 +1,4 @@
FROM ghcr.io/linuxserver/baseimage-ubuntu:noble
FROM ghcr.io/linuxserver/baseimage-ubuntu:noble AS builder
# version, it can be a TAG or a branch
ARG YACR_VERSION="develop"
@ -73,20 +73,34 @@ RUN cd /src/git/YACReaderLibraryServer && \
make && \
make install
# clean up
RUN cd / && \
apt-get clean && \
apt-get purge -y build-essential g++ gcc git make qmake6 qtchooser unzip wget && \
apt-get -y autoremove && \
# install 7z.so with RAR support
RUN echo "Building and installing 7z.so with RAR support..." && \
cd "/src/git/compressed_archive/lib7zip/CPP/7zip/Bundles/Format7zF" && \
make -f makefile.gcc && \
mkdir -p /app/lib/7zip && \
cp ./_o/7z.so /app/lib/7zip
# Stage 2: Runtime stage
FROM ghcr.io/linuxserver/baseimage-ubuntu:noble
# env variables
ENV APPNAME="YACReaderLibraryServer"
ENV HOME="/config"
LABEL maintainer="luisangelsm"
# Copy the built application from the builder stage
COPY --from=builder /app /app
# runtime packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
dos2unix \
libqt6core5compat6-dev \
libpoppler-qt6-dev && \
rm -rf \
/src \
/tmp/* \
/var/cache/apt \
/var/lib/apt/lists/*
libqt6core5compat6 \
libpoppler-qt6-3t64 \
qt6-image-formats-plugins \
libqt6network6t64 \
libqt6sql6-sqlite && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# set ENV
ENV LC_ALL="en_US.UTF-8" \

View File

@ -1,4 +1,4 @@
FROM ghcr.io/linuxserver/baseimage-ubuntu:arm64v8-noble
FROM ghcr.io/linuxserver/baseimage-ubuntu:arm64v8-noble AS builder
# version, it can be a TAG or a branch
ARG YACR_VERSION="develop"
@ -65,17 +65,38 @@ RUN cd /src/git/YACReaderLibraryServer && \
qmake PREFIX=/app CONFIG+="7zip server_standalone" YACReaderLibraryServer.pro && \
make && \
make install
# install 7z.so with RAR support
RUN echo "Building and installing 7z.so with RAR support..." && \
cd "/src/git/compressed_archive/lib7zip/CPP/7zip/Bundles/Format7zF" && \
make -f makefile.gcc && \
mkdir -p /app/lib/7zip && \
cp ./_o/7z.so /app/lib/7zip
# clean up
RUN cd / && \
FROM ghcr.io/linuxserver/baseimage-ubuntu:arm64v8-noble
# env variables
ENV APPNAME="YACReaderLibraryServer"
ENV HOME="/config"
LABEL maintainer="luisangelsm"
# Copy the built application from the builder stage
COPY --from=builder /app /app
# runtime packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libqt5core5a \
libqt5network5 \
libqt5script5 \
libqt5sql5-sqlite \
libqt5sql5 \
libqt5svg5 \
libsqlite3-0 \
libpoppler-qt5-1 \
qt5-image-formats-plugins && \
apt-get clean && \
apt-get purge -y build-essential g++ git make qt5-qmake unzip wget && \
apt-get -y autoremove && \
rm -rf \
/src \
/tmp/* \
/var/cache/apt \
/var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# set ENV
ENV LC_ALL="en_US.UTF-8" \