From e33c12bba149fdfd1943db85f3f82b4d87016730 Mon Sep 17 00:00:00 2001 From: Nicolas Coutin Date: Sat, 2 Nov 2019 16:52:39 +0100 Subject: [PATCH] feat: use linuxserver.io alpine image --- Dockerfile | 31 +++++++++++++++---------------- README.md | 8 +++++++- entrypoint.sh | 4 ++-- root/etc/cont-init.d/30-config | 5 +++++ root/etc/services.d/tor/run | 5 +++++ 5 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 root/etc/cont-init.d/30-config create mode 100644 root/etc/services.d/tor/run diff --git a/Dockerfile b/Dockerfile index 4e997de..ef0d57b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,33 @@ -FROM alpine:3.10 +FROM lsiobase/alpine:3.10 LABEL maintainer "Nicolas Coutin " +ARG DEBIAN_FRONTEND="noninteractive" +ENV XDG_DATA_HOME="/config" \ +XDG_CONFIG_HOME="/config" +ENV TZ America/Los_Angeles + RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories RUN apk update RUN apk --no-cache add bash tzdata tor -ENV TZ America/Los_Angeles -EXPOSE 9001 +EXPOSE 9001 9030 +# TOR configuration through environment variables. ENV RELAY_TYPE relay ENV TOR_ORPort 9001 -ENV TOR_DataDirectory /var/lib/tor +ENV TOR_DataDirectory /data ENV TOR_ContactInfo "Random Person nobody@tor.org" ENV TOR_RelayBandwidthRate "100 KBytes" ENV TOR_RelayBandwidthBurst "200 KBytes" -COPY torrc.bridge.default /etc/tor/torrc.bridge.default -COPY torrc.relay.default /etc/tor/torrc.relay.default -COPY torrc.exit.default /etc/tor/torrc.exit.default - -RUN chown -R tor /etc/tor +# Copy the default configurations. +COPY torrc.bridge.default /config/torrc.bridge.default +COPY torrc.relay.default /config/torrc.relay.default +COPY torrc.exit.default /config/torrc.exit.default COPY entrypoint.sh /entrypoint.sh RUN chmod ugo+rx /entrypoint.sh -USER tor - -RUN mkdir /var/lib/tor/.tor -VOLUME /var/lib/tor/.tor -RUN chown -R tor /var/lib/tor/.tor - -ENTRYPOINT [ "/entrypoint.sh" ] +COPY /root / +VOLUME /data diff --git a/README.md b/README.md index 0b65df2..e2fa1e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # tor-relay-docker -Lightweight TOR relay image, based on Alpine Linux. Configurations can be passed as environment variables. +Lightweight TOR relay image, based on [LinuxServer.io Alpine Linux](https://linuxserver.io). Configurations can be passed as environment variables. [![dockeri.co](https://dockeri.co/image/ilshidur/tor-relay)](https://hub.docker.com/r/ilshidur/tor-relay) @@ -18,6 +18,8 @@ docker run \ -e TOR_RelayBandwidthRate="100 KBytes" \ -e TOR_RelayBandwidthBurst="200 KBytes" \ -e TZ=Europe/London \ + -e PUID=$(id -u) \ + -e PGID=$(id -g) \ -v $(pwd)/tor/data:/var/lib/tor:Z \ -p 9001:9001 \ --restart always \ @@ -36,6 +38,8 @@ docker run \ -e TOR_RelayBandwidthRate="100 KBytes" \ -e TOR_RelayBandwidthBurst="200 KBytes" \ -e TZ=Europe/London \ + -e PUID=$(id -u) \ + -e PGID=$(id -g) \ -v $(pwd)/tor/data:/var/lib/tor:Z \ -p 9001:9001 \ --restart always \ @@ -54,6 +58,8 @@ docker run \ -e TOR_RelayBandwidthRate="100 KBytes" \ -e TOR_RelayBandwidthBurst="200 KBytes" \ -e TZ=Europe/London \ + -e PUID=$(id -u) \ + -e PGID=$(id -g) \ -v $(pwd)/tor/data:/var/lib/tor:Z \ -p 9001:9001 \ --restart always \ diff --git a/entrypoint.sh b/entrypoint.sh index 5c5e7f9..05344c4 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,6 @@ set -e -env | grep '^TOR_' | tr "=" " " | cut -c 5- > /etc/tor/torrc +env | grep '^TOR_' | tr "=" " " | cut -c 5- > /config/torrc -exec tor -f /etc/tor/torrc --defaults-torrc "/etc/tor/torrc.${RELAY_TYPE}.default" +exec tor -f /config/torrc --defaults-torrc "/config/torrc.${RELAY_TYPE}.default" diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config new file mode 100644 index 0000000..616d76a --- /dev/null +++ b/root/etc/cont-init.d/30-config @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bash + +chown -R abc:abc \ + /data \ + /config diff --git a/root/etc/services.d/tor/run b/root/etc/services.d/tor/run new file mode 100644 index 0000000..c2cf7c0 --- /dev/null +++ b/root/etc/services.d/tor/run @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bash + +exec \ + s6-setuidgid abc /entrypoint.sh "${RUN_OPTS}" +