Skip to content

Commit

Permalink
allowing for runtime config of puid & pgid
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Billimek <[email protected]>
  • Loading branch information
billimek committed Nov 20, 2020
1 parent ff9fe28 commit c5294ce
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
28 changes: 13 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ FROM alpine
LABEL maintainer="Gianluca Gabrielli" mail="[email protected]"
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

Expand All @@ -26,6 +26,4 @@ EXPOSE 6881
EXPOSE 6881/udp
EXPOSE 50000

USER rtorrent

CMD ["rtorrent"]
CMD ["/init"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- **UID** : user id (default : 666)
- **GID** : group id (defaut : 666)

## Volumes

There is a volume which maps the directory that rTorrent uses to store session data.
Expand All @@ -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.
13 changes: 9 additions & 4 deletions config.d/01-log.rc
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions init
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c5294ce

Please sign in to comment.