74 lines
2.0 KiB
Docker
74 lines
2.0 KiB
Docker
# Stage 1: Build Tor statically on Alpine Linux
|
|
FROM alpine:latest AS builder
|
|
|
|
# Install necessary dependencies
|
|
RUN apk update && \
|
|
apk add --no-cache \
|
|
build-base \
|
|
linux-headers \
|
|
libevent-dev \
|
|
openssl-dev \
|
|
zlib-dev \
|
|
asciidoc \
|
|
xmlto \
|
|
git \
|
|
automake \
|
|
autoconf \
|
|
libtool \
|
|
musl-dev \
|
|
perl
|
|
|
|
# Create working directory
|
|
WORKDIR /tmp/static_tor
|
|
RUN mkdir install
|
|
|
|
# Compile libevent
|
|
RUN wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz && \
|
|
tar xf libevent-2.1.12-stable.tar.gz && \
|
|
cd libevent-2.1.12-stable && \
|
|
./configure --disable-shared --enable-static --with-pic --prefix=/tmp/static_tor/install && \
|
|
make -j4 && \
|
|
make install && \
|
|
cd ..
|
|
|
|
# Compile OpenSSL
|
|
RUN wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz && \
|
|
tar xf openssl-1.1.1o.tar.gz && \
|
|
cd openssl-1.1.1o && \
|
|
./config no-shared no-dso --prefix=/tmp/static_tor/install && \
|
|
make -j4 && \
|
|
make install && \
|
|
cd ..
|
|
|
|
# Compile zlib
|
|
RUN wget https://zlib.net/fossils/zlib-1.2.12.tar.gz && \
|
|
tar xf zlib-1.2.12.tar.gz && \
|
|
cd zlib-1.2.12 && \
|
|
./configure --static --prefix=/tmp/static_tor/install && \
|
|
make -j4 && \
|
|
make install && \
|
|
cd ..
|
|
|
|
# Compile Tor
|
|
RUN git clone https://git.torproject.org/tor.git && \
|
|
cd tor && \
|
|
git checkout tor-0.4.7.7 && \
|
|
./autogen.sh && \
|
|
./configure --disable-asciidoc --enable-static-tor --with-libevent-dir=/tmp/static_tor/install --with-openssl-dir=/tmp/static_tor/install --with-zlib-dir=/tmp/static_tor/install && \
|
|
make -j4
|
|
|
|
# Stage 2: Create the final image for testing with Alpine
|
|
FROM alpine:latest
|
|
|
|
# Copy the statically compiled Tor binary
|
|
COPY --from=builder /tmp/static_tor/tor/src/or/tor /usr/local/bin/tor
|
|
|
|
# Copy the torrc configuration file
|
|
COPY torrc /usr/local/etc/tor/torrc
|
|
|
|
# Expose Tor relay ports
|
|
EXPOSE 9001 9030
|
|
|
|
# Run Tor
|
|
CMD ["/usr/local/bin/tor", "-f", "/usr/local/etc/tor/torrc"]
|