Update Dockerfile tor service init, refactor rc/ -> misc/

The tor service is now started by calling a script which runs tor
according to the current container user. If the user is root, the script
will begin the tor service as normal. Otherwise, it runs tor as the
current user. This primarily is meant to address the issue with Heroku
builds (which don't have a root user) not being able to start tor as a
service.

Also refactored the rc/ dir to misc/ (with a tor/ subdir) since that
makes more sense.
main
Ben Busby 2020-10-28 22:18:29 -04:00
parent 0ef098069e
commit 7a61220aa5
3 changed files with 9 additions and 2 deletions

View File

@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y \
libssl-dev \ libssl-dev \
tor tor
COPY rc/torrc /etc/tor/torrc COPY misc/tor/torrc /etc/tor/torrc
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
@ -40,4 +40,4 @@ COPY . .
EXPOSE $EXPOSE_PORT EXPOSE $EXPOSE_PORT
CMD service tor start && ./run CMD misc/tor/start-tor.sh & ./run

7
misc/tor/start-tor.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
tor -f /etc/tor/torrc
else
service tor start
fi