diff --git a/dist/docker/Dockerfile b/dist/docker/Dockerfile new file mode 100644 index 000000000..e4d83cef6 --- /dev/null +++ b/dist/docker/Dockerfile @@ -0,0 +1,37 @@ + +FROM alpine:latest AS builder + +ARG BUILD_TYPE +ARG RELEASE + +RUN if [ $RELEASE = "master" ] ; \ + then \ + wget https://github.com/qbittorrent/qBittorrent/archive/refs/heads/master.zip && \ + unzip master.zip && \ + cd qBittorrent-master ; \ + else \ + wget https://github.com/qbittorrent/qBittorrent/archive/refs/tags/release-${RELEASE}.tar.gz && \ + tar xf release-${RELEASE}.tar.gz && \ + cd qBittorrent-release-${RELEASE} ; \ + fi && \ + apk add --no-cache qt6-qttools-dev g++ libtorrent-rasterbar-dev cmake boost-dev ninja && \ + cmake -B build-nox -G "Ninja" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DGUI=OFF -DQT6=ON -DSTACKTRACE=OFF && \ + cmake --build build-nox && \ + cmake --build build-nox --target install/strip + +FROM alpine:latest + +COPY --from=builder /usr/local/bin/qbittorrent-nox /usr/bin/qbittorrent-nox + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh && \ + apk add --no-cache qt6-qtbase libtorrent-rasterbar + +ENV WEBUI_PORT="8080" + +EXPOSE 6881 6881/udp 8080 + +VOLUME /config /downloads + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/dist/docker/Readme.md b/dist/docker/Readme.md new file mode 100644 index 000000000..de49d66d3 --- /dev/null +++ b/dist/docker/Readme.md @@ -0,0 +1,67 @@ +# Docker Container Name + +This Dockerfile allows you to build a qBittorrent-nox container + +## Getting Started + +### Prerequisities + + +In order to run this container you'll need docker installed. + +* [Windows](https://docs.docker.com/windows/started) +* [OS X](https://docs.docker.com/mac/started/) +* [Linux](https://docs.docker.com/linux/started/) + + +## Built + +in the docker folder run + +```shell +release="4.2.0" ; sudo docker build --build-arg BUILD_TYPE=Release --build-arg RELEASE=$release -t qbittorrent-nox:$release --rm . +``` + +where: + +* the `release` variable is the specific tagged version you want to build +* the `BUILD_TYPE` argument is the build you want to create `Debug` or `Release` +* the `RELEASE` argument works as the but is the actual argument given to docker, in the above script is defined by the `release` variable + + +### Usage + +#### Container Variables + +there is one important variable to run the container: + +* the `LEGAL` varible defines if you accept the Legal Notice, put accept as a value only if you understand and accept the Legal Notice + +#### Volumes + +there are two main locations: + +* `downloads` contains the files downloaded by qBittorrent +* `config` contains qBittorrent configurations + +```shell +docker run give.example.org/of/your/container:v0.2.1 parameters +``` + +#### Network + +on the port `8080` the webinterface is run + +#### RUN + +To start the the docker image simply run + +```shell +docker run --env LEGAL=accept -p 8080:8080 -v /your/path/config:/config -v /your/path/download:/downloads --name qBittorrent qbittorrent-nox:4.2.0 +``` + +to stop the container + +```shell +docker stop qBittorrent +``` diff --git a/dist/docker/entrypoint.sh b/dist/docker/entrypoint.sh new file mode 100755 index 000000000..cea7b0f7b --- /dev/null +++ b/dist/docker/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ ! -f /config/qBittorrent/qBittorrent.conf ]; then + mkdir -p /config/qBittorrent/ + cat << EOF > /config/qBittorrent/qBittorrent.conf +[BitTorrent] +Session\DefaultSavePath=/downloads +Session\TempPath=/downloads/temp + +[LegalNotice] +Accepted=false +EOF +fi + +if [ "$LEGAL" = "accept" ] ; then + sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1true|}}' /config/qBittorrent/qBittorrent.conf +else + sed -i '/^\[LegalNotice\]$/{$!{N;s|\(\[LegalNotice\]\nAccepted=\).*|\1false|}}' /config/qBittorrent/qBittorrent.conf +fi + +HOME="/config" XDG_CONFIG_HOME="/config" XDG_DATA_HOME="/config" qbittorrent-nox --webui-port=$WEBUI_PORT