Merge pull request #449 from YACReader/docker-images

Docker images for YACReaderLibraryServer
This commit is contained in:
Luis Ángel San Martín 2024-09-22 17:29:41 +02:00 committed by GitHub
commit 346c9860a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 343 additions and 21 deletions

View File

@ -302,6 +302,52 @@ jobs:
vc_redist_file_name: 'vc_redist.x86.exe'
vc_vars: 'vcvars32.bat'
#
# Docker amd64
#
- job: Docker_Amd64_Image
timeoutInMinutes: 360
dependsOn: CodeFormatValidation
displayName: 'Build amd64 Docker Image'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
cd $(Build.SourcesDirectory)/docker/
docker build --no-cache --platform linux/amd64 -f Dockerfile -t yacreaderlibraryserver:develop-amd64 .
docker save yacreaderlibraryserver:develop-amd64 -o $(Build.ArtifactStagingDirectory)/amd64.tar
displayName: 'Build amd64 Image and Save as Artifact'
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/amd64.tar
artifactName: amd64_image
displayName: 'Publish amd64 Image Artifact'
#
# Docker arm64
#
- job: Docker_Arm64_Image
timeoutInMinutes: 360
dependsOn: CodeFormatValidation
displayName: 'Build arm64 Docker Image'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
cd $(Build.SourcesDirectory)/docker/
docker buildx create --use
docker buildx inspect --bootstrap
docker buildx build --no-cache --platform linux/arm64 -f Dockerfile.aarch64 -t yacreaderlibraryserver:develop-arm64 --load .
docker save yacreaderlibraryserver:develop-arm64 -o $(Build.ArtifactStagingDirectory)/arm64.tar
displayName: 'Build arm64 Image and Save as Artifact'
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/arm64.tar
artifactName: arm64_image
displayName: 'Publish arm64 Image Artifact'
#
# Dev builds publication
#
@ -317,6 +363,7 @@ jobs:
- Windows_x86
- Windows_x64
- Windows_x64_qt6
- BuildDockerImages
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), true)
variables:
- group: github-releases
@ -327,6 +374,16 @@ jobs:
inputs:
buildType: 'current'
targetPath: $(Build.ArtifactStagingDirectory)
- script: |
docker load -i $(Build.ArtifactStagingDirectory)/amd64.tar
docker load -i $(Build.ArtifactStagingDirectory)/arm64.tar
docker manifest create yacreaderlibraryserver:develop \
--amend yacreaderlibraryserver:develop-amd64 \
--amend yacreaderlibraryserver:develop-arm64
docker manifest inspect yacreaderlibraryserver:develop
rm $(Build.ArtifactStagingDirectory)/amd64.tar
rm $(Build.ArtifactStagingDirectory)/arm64.tar
displayName: 'Load Multi-Platform Docker Image'
- script: |
find $(Build.ArtifactStagingDirectory) -name '*.*' -exec cp {} $(Build.ArtifactStagingDirectory) \;
displayName: 'flatten artifact staging directory'
@ -334,7 +391,15 @@ jobs:
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' ).$(Build.BuildNumber)"
echo "##vso[task.setvariable variable=VERSION]$VERSION"
displayName: 'Version'
- task: GitHubRelease@0
- task: Docker@2
displayName: 'Push Multi-Platform Docker Image'
inputs:
command: 'push'
repository: yacreaderlibraryserver
tags: |
develop
containerRegistry: $(docker-hub)
- task: GitHubRelease@1
inputs:
gitHubConnection: yacreader-releases
repositoryName: YACReader/yacreader-dev-builds
@ -359,6 +424,7 @@ jobs:
- Windows_x86
- Windows_x64
- Windows_x64_qt6
- BuildDockerImages
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
variables:
- group: github-releases
@ -369,6 +435,17 @@ jobs:
inputs:
buildType: 'current'
targetPath: $(Build.ArtifactStagingDirectory)
- script: |
docker load -i $(Build.ArtifactStagingDirectory)/amd64.tar
docker load -i $(Build.ArtifactStagingDirectory)/arm64.tar
docker manifest create yacreaderlibraryserver:latest \
--amend yacreaderlibraryserver:develop-amd64 \
--amend yacreaderlibraryserver:develop-arm64
docker manifest inspect yacreaderlibraryserver:latest
rm $(Build.ArtifactStagingDirectory)/amd64.tar
rm $(Build.ArtifactStagingDirectory)/arm64.tar
docker tag yacreaderlibraryserver:latest yacreaderlibraryserver:$(VERSION)
displayName: 'Load docker image with latest and VERSION tags'
- script: |
find $(Build.ArtifactStagingDirectory) -name '*.*' -exec cp {} $(Build.ArtifactStagingDirectory) \;
displayName: 'flatten artifact staging directory'
@ -376,7 +453,16 @@ jobs:
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "##vso[task.setvariable variable=VERSION]$VERSION"
displayName: 'Version'
- task: GitHubRelease@0
- task: Docker@2
displayName: 'Push Multi-Platform Docker Image'
inputs:
command: 'push'
repository: yacreaderlibraryserver
tags: |
latest
$(VERSION)
containerRegistry: $(docker-hub)
- task: GitHubRelease@1
inputs:
gitHubConnection: yacreader-releases
title: $(VERSION)

View File

@ -1,6 +1,6 @@
## Ubuntu 22.04 build script
You can use `build.sh` to build YACReader from scratch in `Ubuntu 22.04` with `7zip` (including `RAR5` support) and `poppler` (pdf). This build uses Qt5.
The script will create a folder next to it where all the downloads and building will happen, it will also install all the required dependencies. 7zip 23.01 is not available in `Ubuntu 22.04` so the script builds it and installs 7z.so in /usr/lib/7zip/. Once the scrip finishes succesfully `YACReader`, `YACReaderLibrary` and `YACReaderLibraryServer` should be installed in your system.
The script will create a folder next to it where all the downloads and building will happen, it will also install all the required dependencies. The installs 7z.so in /usr/lib/7zip/. Once the scrip finishes succesfully `YACReader`, `YACReaderLibrary` and `YACReaderLibraryServer` should be installed in your system.
WARNIG: This doesn't work with the latest release (9.14), there is a bug and some of the code is still looking for the old p7zip library, you need to build from develop, to do so run: `build.sh develop`.

View File

@ -1,6 +1,6 @@
## Ubuntu 24.04 build script
You can use `build.sh` to build YACReader from scratch in `Ubuntu 24.04` with `7zip` (including `RAR5` support) and `poppler` (pdf). This build uses `Qt6`.
The script will create a folder next to it where all the downloads and building will happen, it will also install all the required dependencies. Once the scrip finishes succesfully `YACReader`, `YACReaderLibrary` and `YACReaderLibraryServer` should be installed in your system.
The script will create a folder next to it where all the downloads and building will happen, it will also install all the required dependencies. The script builds it and installs 7z.so in /usr/lib/7zip/. Once the scrip finishes succesfully `YACReader`, `YACReaderLibrary` and `YACReaderLibraryServer` should be installed in your system.
WARNIG: This doesn't work with the latest release (9.14), there is a bug and some of the code is still looking for the old p7zip library, you need to build from develop, to do so run: `build.sh develop`.

View File

@ -40,7 +40,7 @@ mkdir -p "$COMPRESSED_ARCHIVE_DIR"
# Step 2: Install required packages
echo "Updating package list and installing required packages..."
sudo apt-get update
sudo apt-get install -y qtchooser qt6-tools-dev qt6-base-dev-tools qmake6 qmake6-bin qt6-base-dev qt6-multimedia-dev qt6-tools-dev-tools libgl-dev qt6-l10n-tools libqt6opengl6-dev qt6-declarative-dev libqt6svg6-dev libqt6core5compat6-dev qml6-module-qt5compat-graphicaleffects qt6-5compat-dev libpoppler-qt6-dev qt6-image-formats-plugins qml6-module-qtquick-controls qml6-module-qtquick-layouts qml6-module-qtqml-workerscript qml6-module-qtquick-templates p7zip-full p7zip-rar git build-essential
sudo apt-get install -y qtchooser qt6-tools-dev qt6-base-dev-tools qmake6 qmake6-bin qt6-base-dev qt6-multimedia-dev qt6-tools-dev-tools libgl-dev qt6-l10n-tools libqt6opengl6-dev qt6-declarative-dev libqt6svg6-dev libqt6core5compat6-dev qml6-module-qt5compat-graphicaleffects qt6-5compat-dev libpoppler-qt6-dev qt6-image-formats-plugins qml6-module-qtquick-controls qml6-module-qtquick-layouts qml6-module-qtqml-workerscript qml6-module-qtquick-templates 7zip-full 7zip-rar git build-essential
# Step 3: Download YACReader source code
if [ "$1" == "develop" ]; then
@ -60,14 +60,21 @@ wget "$SEVENZIP_URL" -O "$SEVENZIP_ARCHIVE"
echo "Extracting 7zip source code..."
7z x "$SEVENZIP_ARCHIVE" -o"$SEVENZIP_DIR"
# Step 5: Build YACReader
# Step 5: Build and install 7z.so with RAR support
echo "Building and installing 7z.so with RAR support..."
cd "$SEVENZIP_DIR/CPP/7zip/Bundles/Format7zF"
make -f makefile.gcc
sudo mkdir -p /usr/lib/7zip
sudo cp ./_o/7z.so /usr/lib/7zip
# Step 6: Build YACReader
echo "Building YACReader..."
cd "$YACREADER_DIR"
export DEFINES_VAR=DEFINES+\=\"BUILD_NUMBER=\\\\\\\"CUSTOM_BUILD\\\\\\\"\"
qmake6 CONFIG+="7zip" $DEFINES_VAR
make
# Step 6: Install YACReader
# Step 7: Install YACReader
echo "Installing YACReader..."
sudo make install

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

115
docker/Dockerfile Normal file
View File

@ -0,0 +1,115 @@
FROM ghcr.io/linuxserver/baseimage-ubuntu:noble AS builder
# version, it can be a TAG or a branch
ARG YACR_VERSION="develop"
# env variables
ARG DEBIAN_FRONTEND="noninteractive"
ENV APPNAME="YACReaderLibraryServer"
ENV HOME="/config"
LABEL maintainer="luisangelsm"
# install build packages
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
desktop-file-utils \
gcc \
g++ \
git \
qt6-tools-dev \
qt6-base-dev-tools \
qmake6 \
qmake6-bin \
qt6-base-dev \
qt6-multimedia-dev \
qt6-tools-dev-tools \
libgl-dev \
qt6-l10n-tools \
libqt6opengl6-dev \
libunarr-dev \
qt6-declarative-dev \
libqt6svg6-dev \
libqt6core5compat6-dev \
libbz2-dev \
libglu1-mesa-dev \
liblzma-dev \
libqt6gui6 \
libqt6multimedia6 \
libqt6network6 \
libqt6qml6 \
libqt6quickcontrols2-6 \
qt6-image-formats-plugins \
libqt6sql6 \
libqt6sql6-sqlite \
make \
sqlite3 \
libsqlite3-dev \
unzip \
wget \
7zip \
7zip-rar \
libpoppler-qt6-dev \
zlib1g-dev && \
ldconfig
# clone YACReader repo
RUN git clone https://github.com/YACReader/yacreader.git /src/git && \
cd /src/git && \
git checkout $YACR_VERSION
# get 7zip source
RUN cd /src/git/compressed_archive && \
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O /src/git/compressed_archive/7z2301-src.7z && \
7z x /src/git/compressed_archive/7z2301-src.7z -o/src/git/compressed_archive/lib7zip
# build yacreaderlibraryserver
RUN cd /src/git/YACReaderLibraryServer && \
qmake6 PREFIX=/app CONFIG+="7zip server_standalone" YACReaderLibraryServer.pro && \
qmake6 -v && \
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
# 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 \
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" \
PATH="/app/bin:${PATH}"
# copy files
COPY root.tar.gz /
# Extract the contents of root.tar.gz into the / directory
RUN tar -xvpzf /root.tar.gz -C /
# ports and volumes
EXPOSE 8080
VOLUME ["/config", "/comics"]

112
docker/Dockerfile.aarch64 Normal file
View File

@ -0,0 +1,112 @@
FROM ghcr.io/linuxserver/baseimage-ubuntu:arm64v8-noble AS builder
# version, it can be a TAG or a branch
ARG YACR_VERSION="develop"
# env variables
ARG DEBIAN_FRONTEND="noninteractive"
ENV APPNAME="YACReaderLibraryServer"
ENV HOME="/config"
LABEL maintainer="luisangelsm"
# install build packages
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
desktop-file-utils \
g++ \
git \
libglu1-mesa-dev \
libpoppler-qt5-dev \
libpoppler-qt5-1 \
libqt5core5a \
libqt5gui5 \
libqt5multimedia5 \
libqt5network5 \
libqt5opengl5-dev \
libqt5qml5 \
libqt5quickcontrols2-5 \
libqt5script5 \
libqt5sql5-sqlite \
libqt5sql5 \
libqt5svg5-dev \
libsqlite3-dev \
make \
7zip \
7zip-rar \
qtchooser \
qtbase5-dev-tools \
qt5-qmake \
qtbase5-dev \
qtmultimedia5-dev \
qt5-image-formats-plugins \
qtdeclarative5-dev \
qtquickcontrols2-5-dev \
qtscript5-dev \
qttools5-dev-tools \
sqlite3 \
unzip \
wget && \
ldconfig
# clone YACReader repo
RUN git clone https://github.com/YACReader/yacreader.git /src/git && \
cd /src/git && \
git checkout $YACR_VERSION
# get 7zip source
RUN cd /src/git/compressed_archive && \
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O /src/git/compressed_archive/7z2301-src.7z && \
7z x /src/git/compressed_archive/7z2301-src.7z -o/src/git/compressed_archive/lib7zip
# build yacreaderlibraryserver
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
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 && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# set ENV
ENV LC_ALL="en_US.UTF-8" \
PATH="/app/bin:${PATH}"
# copy files
COPY root.tar.gz /
# Extract the contents of root.tar.gz into the / directory
RUN tar -xvpzf /root.tar.gz -C /
# ports and volumes
EXPOSE 8080
VOLUME ["/config", "/comics"]

16
docker/README.md Normal file
View File

@ -0,0 +1,16 @@
These are the official Dockerfile for YACReaderLibraryServer.
By default the images will be created using the `develop` branch from YACReader's Github repository. You can pass the `YACR_VESRION` argument with a tag to build one of the relase versions, e.g. `ARG YACR_VERSION=9.15.0`
This is an example about how to run YACReaderLibraryServer:
```
docker run -d --name YACReaderLibraryServer -e PUID=99 -e PGID=100 -e TZ=Europe/Madrid -p 9999:8080 -v 'C:\Users\my_user_name\Desktop\:/config' -v 'C:\Users\my_user_name\Desktop\MyLibrary:/comics' --restart unless-stopped yacreaderlibraryserver:latest
```
`-p` sets the port that needs to be used in the iOS and Android apps, in the example above the port would be 9999. This port connects with the port 8080 in the container, and that would be the port that the server will be seeing.
`-v 'path:/comics'` sets the path to the folder containing your library in your real machine. This path is connected to the /comics volumen, and this is the path that the server will seen in the container.
`root.tar.gz` contains some default configuration + `s6-overlay` files that take care of keeping `YACReaderLibraryServer` running (and starting it automatically when the docker image starts), the files inside need to be carefully edited in linux to avoid having trobules at runtime, since I normally develop on Windows the `tar.gz` keeps the integrity of the files.
The images are pushed to `yacreader/yacreaderlibraryserver` in Docker Hub. The tags `:develop`, `:latest` and the version number are available. `:develop` will contain an image with the latest dev build, while `:latest` will point to the latest stable release.

BIN
docker/root.tar.gz Normal file

Binary file not shown.