From 1ae5339c33c1eb0b21352e912869f2fc64f3d9e4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 5 May 2022 20:56:11 +0800 Subject: [PATCH] Add script for docker-compose --- dist/docker/.env | 8 +++ dist/docker/Readme.md | 92 +++++++++++++++++++++------------- dist/docker/docker-compose.yml | 25 +++++++++ 3 files changed, 90 insertions(+), 35 deletions(-) create mode 100644 dist/docker/.env create mode 100644 dist/docker/docker-compose.yml diff --git a/dist/docker/.env b/dist/docker/.env new file mode 100644 index 000000000..27246a6b4 --- /dev/null +++ b/dist/docker/.env @@ -0,0 +1,8 @@ +# refer to Readme.md for an explanation of the variables + +QBT_EULA= +QBT_VERSION=devel +QBT_WEBUI_PORT=8080 + +QBT_CONFIG_PATH=/config +QBT_DOWNLOADS_PATH=/downloads diff --git a/dist/docker/Readme.md b/dist/docker/Readme.md index df7e57397..4d19295dd 100644 --- a/dist/docker/Readme.md +++ b/dist/docker/Readme.md @@ -4,70 +4,92 @@ This Dockerfile allows you to build a docker image containing qBittorrent-nox ## Prerequisities -In order to build/run this image you'll need docker installed: https://docs.docker.com/get-docker/ +In order to build/run this image you'll need `docker` installed: https://docs.docker.com/get-docker/ + +It is also recommended to install `docker-compose` as it can significantly ease the process: https://docs.docker.com/compose/install/ ## Building docker image -In this docker folder run: -```shell -export \ - QBT_VERSION=devel -docker build \ - --build-arg QBT_VERSION \ - -t qbittorrent-nox:"$QBT_VERSION" \ - . -``` +* If you are using docker (not docker-compose) then run the following commands in this folder: + ```shell + export \ + QBT_VERSION=devel + docker build \ + --build-arg QBT_VERSION \ + -t qbittorrent-nox:"$QBT_VERSION" \ + . + ``` + +* If you are using docker-compose then you should edit `.env` file first. + You can find an explaination of the variables in the following [Parameters](#parameters) section. \ + Then run the following commands in this folder: + ```shell + docker compose build \ + --build-arg QBT_VERSION + ``` ### Parameters -* `QBT_VERSION` +#### Environment variables + +* `QBT_EULA` \ + This environment variable defines whether you accept the end-user license agreement (EULA) of qBittorrent. \ + **Put `accept` only if you understand and accepted the EULA.** You can find + the EULA [here](https://github.com/qbittorrent/qBittorrent/blob/56667e717b82c79433ecb8a5ff6cc2d7b315d773/src/app/main.cpp#L320-L323). +* `QBT_VERSION` \ This environment variable specifies the version of qBittorrent-nox to be built. \ For example, `4.4.0` is a valid entry. You can find all tagged versions [here](https://github.com/qbittorrent/qBittorrent/tags). \ Or you can put `devel` to build the latest development version. +* `QBT_WEBUI_PORT` \ + This environment variable sets the port number which qBittorrent WebUI will be binded to. + +#### Volumes + +There are some paths involved: +* `/config` on your host machine will contain qBittorrent configurations +* `/downloads` on your host machine will contain the files downloaded by qBittorrent -## Running docker image +## Running container -* To start the the docker image simply run: +* Using docker (not docker-compose), simply run: ```shell export \ - QBT_VERSION=devel \ QBT_EULA=accept \ - QBT_WEBUI_PORT=8080 + QBT_VERSION=devel \ + QBT_WEBUI_PORT=8080 \ + QBT_CONFIG_PATH="/tmp/bbb/config" + QBT_DOWNLOADS_PATH="/tmp/bbb/downloads" docker run \ - -it \ + -t \ --read-only \ --rm \ --tmpfs /tmp \ --name qbittorrent-nox \ -e QBT_EULA \ -e QBT_WEBUI_PORT \ - -p "$QBT_WEBUI_PORT":"$QBT_WEBUI_PORT" \ + -p "$QBT_WEBUI_PORT":"$QBT_WEBUI_PORT"/tcp \ -p 6881:6881/tcp \ -p 6881:6881/udp \ - -v /config:/config \ - -v /downloads:/downloads \ + -v "$QBT_CONFIG_PATH":/config \ + -v "$QBT_DOWNLOADS_PATH":/downloads \ qbittorrent-nox:"$QBT_VERSION" ``` - Then you can login at: `http://127.0.0.1:8080` -* To stop the container: +* Using docker-compose: ```shell - docker stop -t 1800 qbittorrent-nox + docker compose up ``` -### Parameters +Then you can login at: `http://127.0.0.1:8080` -* `QBT_VERSION` \ - The same as [above](#variables). -* `QBT_EULA` \ - This environment variable defines whether you accept the end-user license agreement (EULA) of qBittorrent. \ - Put `accept` only if you understand and accepted the EULA. You can find - the EULA [here](https://github.com/qbittorrent/qBittorrent/blob/56667e717b82c79433ecb8a5ff6cc2d7b315d773/src/app/main.cpp#L320-L323). -* `QBT_WEBUI_PORT` \ - This environment variable sets the port number which qBittorrent WebUI will be binded to. +## Stopping container -### Volumes +* Using docker (not docker-compose): + ```shell + docker stop -t 1800 qbittorrent-nox + ``` -There are some paths involved: -* `/config` on your host machine will contain qBittorrent configurations -* `/downloads` on your host machine will contain the files downloaded by qBittorrent +* Using docker-compose: + ```shell + docker compose down + ``` diff --git a/dist/docker/docker-compose.yml b/dist/docker/docker-compose.yml new file mode 100644 index 000000000..c5cab9846 --- /dev/null +++ b/dist/docker/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3.9" + +services: + qbittorrent-nox: + build: . + container_name: qbittorrent-nox + environment: + - QBT_EULA=${QBT_EULA} + - QBT_VERSION=${QBT_VERSION} + - QBT_WEBUI_PORT=${QBT_WEBUI_PORT} + image: qbittorrent-nox:${QBT_VERSION} + ports: + # for bittorrent traffic + - 6881:6881/tcp + - 6881:6881/udp + # for WebUI + - ${QBT_WEBUI_PORT}:${QBT_WEBUI_PORT}/tcp + read_only: true + stop_grace_period: 30m + tmpfs: + - /tmp + tty: true + volumes: + - ${QBT_CONFIG_PATH}:/config + - ${QBT_DOWNLOADS_PATH}:/downloads