FROM amd64/debian:buster

RUN apt-get update && \
    apt-get dist-upgrade -y && \
    apt-get install -y nodejs npm build-essential libevent-dev libssl-dev patch wget tar zlib1g-dev

COPY enable-one-hop.patch /root/enable-one-hop.patch

RUN wget https://www.torproject.org/dist/tor-0.3.5.7.tar.gz && \
    tar xf tor-0.3.5.7.tar.gz && \
    rm tor-0.3.5.7.tar.gz && \
    cd tor-0.3.5.7 && \
    patch -p1 < /root/enable-one-hop.patch && \
    ./configure && \
    make && \
    make install

COPY client.js /root/client.js
COPY package.json /root/package.json
COPY package-lock.json /root/package-lock.json

WORKDIR /root
RUN npm install

COPY torrc /root/torrc