Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Migrate to default directory structure. #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
FROM ubuntu
FROM debian:jessie

MAINTAINER "Patrick O'Doherty <[email protected]>"

EXPOSE 9001
ENV VERSION 0.2.5.10
ENV DEBIAN_FRONTEND noninteractive

ADD apt-pinning /etc/apt/preferences.d/pinning
RUN echo 'deb http://deb.torproject.org/torproject.org jessie main' > /etc/apt/sources.list.d/tor.list && \
gpg --keyserver keys.gnupg.net --recv 886DDD89 && \
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -
RUN apt-get update && apt-get install -y \
build-essential \
curl \
libevent-dev \
libssl-dev
deb.torproject.org-keyring \
obfsproxy \
openssl \
tor

RUN curl https://dist.torproject.org/tor-${VERSION}.tar.gz | tar xz -C /tmp
# tor-arm does not work in Docker container:
# _curses.error: setupterm: could not find terminal
# Install outside of the Docker container if required.

RUN cd /tmp/tor-${VERSION} && ./configure
RUN cd /tmp/tor-${VERSION} && make
RUN cd /tmp/tor-${VERSION} && make install
WORKDIR /var/lib/tor

ADD ./torrc /etc/torrc
# Allow you to upgrade your relay without having to regenerate keys
VOLUME /.tor
VOLUME /var/lib/tor

VOLUME /.tor
# Legacy … can be removed when all users have updated and run the new container once.

# Generate a random nickname for the relay
RUN echo "Nickname docker$(head -c 16 /dev/urandom | sha1sum | cut -c1-10)" >> /etc/torrc
ADD bootstrap.sh /usr/bin/
RUN chmod +x /usr/bin/bootstrap.sh

CMD /usr/local/bin/tor -f /etc/torrc
CMD /usr/bin/bootstrap.sh
3 changes: 3 additions & 0 deletions apt-pinning
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Package: *
Pin: origin "deb.torproject.org"
Pin-Priority: 800
12 changes: 12 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

if [ -d "/root/.tor" ]; then
echo "Clean up legacy stuff."
mv /root/.tor/* /var/lib/tor
rmdir "/root/.tor"
fi

chown root:root /var/lib/tor -R
chmod a=,u=rwX /var/lib/tor -R

/usr/bin/tor -f /etc/torrc
2 changes: 2 additions & 0 deletions torrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Log notice stdout
ExitPolicy reject *:*
# User debian-tor
DataDirectory /var/lib/tor
ORPort 9001