diff --git a/Dockerfile b/Dockerfile index 3730f0a..818888d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,21 +3,21 @@ FROM alpine LABEL maintainer="Gianluca Gabrielli" mail="tuxmealux+dockerhub@protonmail.com" LABEL description="rTorrent on Alpine Linux, with a better Docker integration." LABEL website="https://github.com/TuxMeaLux/alpine-rtorrent" -LABEL version="1.0" +LABEL version="1.1" -ARG UGID=666 - -RUN addgroup -g $UGID rtorrent && \ - adduser -S -u $UGID -G rtorrent rtorrent && \ - apk add --no-cache rtorrent && \ +RUN apk upgrade && \ + apk add --no-cache rtorrent su-exec && \ mkdir -p /home/rtorrent/rtorrent/config.d && \ - mkdir /home/rtorrent/rtorrent/.session && \ - mkdir /home/rtorrent/rtorrent/download && \ - mkdir /home/rtorrent/rtorrent/watch && \ - chown -R rtorrent:rtorrent /home/rtorrent/rtorrent + mkdir -p /home/rtorrent/rtorrent/.session && \ + mkdir -p /home/rtorrent/rtorrent/download && \ + mkdir -p /home/rtorrent/rtorrent/watch && \ + ln -sf /dev/stdout /var/log/rtorrent-info.log && \ + ln -sf /dev/stderr /var/log/rtorrent-error.log && \ + rm -rf /var/cache/apk/* -COPY --chown=rtorrent:rtorrent config.d/ /home/rtorrent/rtorrent/config.d/ -COPY --chown=rtorrent:rtorrent .rtorrent.rc /home/rtorrent/ +COPY config.d/ /home/rtorrent/rtorrent/config.d/ +COPY .rtorrent.rc /home/rtorrent/ +COPY init / VOLUME /home/rtorrent/rtorrent/.session @@ -26,6 +26,4 @@ EXPOSE 6881 EXPOSE 6881/udp EXPOSE 50000 -USER rtorrent - -CMD ["rtorrent"] +CMD ["/init"] diff --git a/README.md b/README.md index a253a01..6da8cbe 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ If you are looking for a fast way to either run rTorrent and Flood using just on If it's not your intention to control rTorrent from a third-party application, do not use port ```16891```. +## Environment variables +- **PUID** : user id (default : 666) +- **PGID** : group id (defaut : 666) + ## Volumes There is a volume which maps the directory that rTorrent uses to store session data. @@ -66,5 +70,5 @@ There are two directories that should be mapped outside the container. ## Logs -To let rTorrent becomes more docker compliant, I've configured logs to be written on ```/dev/stdout```. In this way, it is possible to catch them with [docker logs](https://docs.docker.com/engine/reference/commandline/logs/). +To let rTorrent becomes more docker compliant, I've configured logs to be written on ```/dev/stdout``` & ```/dev/stderr```. In this way, it is possible to catch them with [docker logs](https://docs.docker.com/engine/reference/commandline/logs/). This behavior can be changed editing the [```config.d/01-log.rc```](config.d/01-log.rc) file. diff --git a/config.d/01-log.rc b/config.d/01-log.rc index f90e44a..4d80345 100644 --- a/config.d/01-log.rc +++ b/config.d/01-log.rc @@ -1,6 +1,11 @@ ## Logging: ## Levels = critical error warn notice info debug -method.insert = cfg.logfile, private|const|string, (cat,"/dev/stdout") -log.open_file = "log", (cfg.logfile) -log.add_output = "info", "log" -log.add_output = "torrent_info", "log" +method.insert = cfg.logs, private|const|string, (cat,"/var/log/") +method.insert = cfg.info_logfile, private|const|string, (cat,(cfg.logs),"rtorrent-info.log") +method.insert = cfg.error_logfile, private|const|string, (cat,(cfg.logs),"rtorrent-error.log") +log.open_file = "info-log", (cfg.info_logfile) +log.add_output = "info", "info-log" +log.open_file = "error-log", (cfg.error_logfile) +log.add_output = "critical", "error-log" +log.add_output = "error", "error-log" +log.add_output = "warn", "error-log" \ No newline at end of file diff --git a/init b/init new file mode 100755 index 0000000..b866e9a --- /dev/null +++ b/init @@ -0,0 +1,14 @@ +#!/bin/sh +PUID=${PUID:=666} +PGID=${PGID:=666} + +# chown rTorrent home directory +chown -R "$PUID:$PGID" /home/rtorrent + +chown "$PUID:$PGID" \ + /var/log/rtorrent-error.log \ + /var/log/rtorrent-info.log + +cd /home/rtorrent + +exec su-exec $PUID:$PGID rtorrent -n -o import=/home/rtorrent/.rtorrent.rc