Skip to content

Commit

Permalink
Merge pull request #212 from linuxserver/master-nonroot
Browse files Browse the repository at this point in the history
  • Loading branch information
thespad authored Jan 14, 2025
2 parents 4ac3d0e + 556ce51 commit 6f12d83
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 35 deletions.
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ RUN \
apk add --no-cache --upgrade --virtual=build-dependencies \
build-base && \
echo "**** install packages ****" && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:deluge$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add --no-cache --upgrade --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
deluge==${DELUGE_VERSION} \
python3 \
py3-future \
py3-geoip \
py3-requests \
p7zip && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:deluge$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add -U --upgrade --no-cache \
deluge==${DELUGE_VERSION} && \
echo "**** grab GeoIP database ****" && \
curl -L --retry 10 --retry-max-time 60 --retry-all-errors \
"https://mailfud.org/geoip-legacy/GeoIP.dat.gz" \
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ RUN \
apk add --no-cache --upgrade --virtual=build-dependencies \
build-base && \
echo "**** install packages ****" && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:deluge$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add --no-cache --upgrade --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
deluge==${DELUGE_VERSION} \
python3 \
py3-future \
py3-geoip \
py3-requests \
p7zip && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:deluge$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add -U --upgrade --no-cache \
deluge==${DELUGE_VERSION} && \
echo "**** grab GeoIP database ****" && \
curl -L --retry 10 --retry-max-time 60 --retry-all-errors \
"https://mailfud.org/geoip-legacy/GeoIP.dat.gz" \
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Find us at:
* Plugin System
* Much more...

[![deluge](https://avatars2.githubusercontent.com/u/6733935?v=3&s=200)](http://deluge-torrent.org/)
[![deluge](https://raw.githubusercontent.com/linuxserver/docker-templates/blob/master/linuxserver.io/img/deluge-logo.png)](http://deluge-torrent.org/)

## Supported Architectures

Expand Down Expand Up @@ -83,6 +83,10 @@ Change the inbound port to 6881 (or whichever port you've mapped for the contain

This image can be run with a read-only container filesystem. For details please [read the docs](https://docs.linuxserver.io/misc/read-only/).

## Non-Root Operation

This image can be run with a non-root user. For details please [read the docs](https://docs.linuxserver.io/misc/non-root/).

## Usage

To help you get started creating a container from this image you can either use docker-compose or the docker cli.
Expand Down Expand Up @@ -150,6 +154,7 @@ Containers are configured using parameters passed at runtime (such as those abov
| `-v /config` | deluge configs |
| `-v /downloads` | torrent download directory |
| `--read-only=true` | Run container with a read-only filesystem. Please [read the docs](https://docs.linuxserver.io/misc/read-only/). |
| `--user=1000:1000` | Run container with a non-root user. Please [read the docs](https://docs.linuxserver.io/misc/non-root/). |

## Environment variables from files (Docker secrets)

Expand Down Expand Up @@ -313,6 +318,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **12.01.25:** - Rebase libtorrentv1 branch to Alpine 3.21.
* **19.09.24:** - Prevent race condition related delay during container stop.
* **26.08.24:** - Add libtorrentv1 tag.
* **26.12.23:** - Replace source for GeoIP database.
Expand Down
4 changes: 3 additions & 1 deletion readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# project information
project_name: deluge
project_url: "http://deluge-torrent.org/"
project_logo: "https://avatars2.githubusercontent.com/u/6733935?v=3&s=200"
project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/blob/master/linuxserver.io/img/deluge-logo.png"
project_blurb: |
[{{ project_name|capitalize }}]({{ project_url }}) is a lightweight, Free Software, cross-platform BitTorrent client.
Expand Down Expand Up @@ -40,6 +40,7 @@ opt_param_usage_include_ports: true
opt_param_ports:
- {external_port: "58846", internal_port: "58846", port_desc: "Default deluged port for thin client connectivity"}
readonly_supported: true
nonroot_supported: true
# application setup block
app_setup_block_enabled: true
app_setup_block: |
Expand Down Expand Up @@ -92,6 +93,7 @@ init_diagram: |
"deluge:latest" <- Base Images
# changelog
changelogs:
- {date: "12.01.25:", desc: "Rebase libtorrentv1 branch to Alpine 3.21."}
- {date: "19.09.24:", desc: "Prevent race condition related delay during container stop."}
- {date: "26.08.24:", desc: "Add libtorrentv1 tag."}
- {date: "26.12.23:", desc: "Replace source for GeoIP database."}
Expand Down
27 changes: 14 additions & 13 deletions root/etc/s6-overlay/s6-rc.d/init-deluge-config/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ fi

mkdir -p /run/deluged-temp

# permissions
lsiown -R abc:abc \
/run/deluged-temp \
/config

# chown download directory if currently not set to abc
if [[ -d /downloads ]]; then
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
lsiown -R abc:abc /downloads
fi
fi

# create torrents directory if it does not exist
if [[ ! -d /config/torrents ]]; then
mkdir -p /config/torrents
lsiown abc:abc /config/torrents
fi

if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
# permissions
lsiown -R abc:abc \
/run/deluged-temp \
/config

# chown download directory if currently not set to abc
if [[ -d /downloads ]]; then
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
lsiown -R abc:abc /downloads
fi
fi
fi
13 changes: 9 additions & 4 deletions root/etc/s6-overlay/s6-rc.d/svc-deluge-web/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ if [[ -f /config/web.conf ]]; then
DELUGE_WEB_PORT=$(grep 'port"' /config/web.conf | tr -cd "[:digit:]")
fi

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGE_WEB_PORT:-8112}" \
s6-setuidgid abc /usr/bin/deluge-web \
-d -c /config --loglevel="${DELUGE_LOGLEVEL}"
if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGE_WEB_PORT:-8112}" \
s6-setuidgid abc /usr/bin/deluge-web -d -c /config --loglevel="${DELUGE_LOGLEVEL}"
else
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGE_WEB_PORT:-8112}" \
/usr/bin/deluge-web -d -c /config --loglevel="${DELUGE_LOGLEVEL}"
fi
13 changes: 9 additions & 4 deletions root/etc/s6-overlay/s6-rc.d/svc-deluged/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ if [[ -f /config/core.conf ]]; then
DELUGED_PORT=$(grep '"daemon_port"' /config/core.conf | tr -cd "[:digit:]")
fi

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGED_PORT:-58846}" \
s6-setuidgid abc /usr/bin/deluged -c /config \
-d --loglevel="${DELUGE_LOGLEVEL}"
if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGED_PORT:-58846}" \
s6-setuidgid abc /usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}"
else
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${DELUGED_PORT:-58846}" \
/usr/bin/deluged -c /config -d --loglevel="${DELUGE_LOGLEVEL}"
fi

0 comments on commit 6f12d83

Please sign in to comment.