tor-relay
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Colin 2024-05-23 12:03:24 -04:00
parent f9b904b4f2
commit c4b213cbb7
1 changed files with 38 additions and 16 deletions

View File

@ -1,4 +1,4 @@
# Stage 1: Build Tor from source on Alpine Linux
# Stage 1: Build Tor statically on Alpine Linux
FROM alpine:latest AS builder
# Install necessary dependencies
@ -15,28 +15,50 @@ RUN apk update && \
autoconf \
libtool
# Download and compile Tor
# 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 http://zlib.net/zlib-1.2.11.tar.gz && \
tar xf zlib-1.2.11.tar.gz && \
cd zlib-1.2.11 && \
./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 && \
make && \
make install
./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 minimal image with Tor
FROM scratch
# Copy necessary files from the builder stage
COPY --from=builder /usr/local/bin/tor /usr/local/bin/tor
COPY --from=builder /usr/local/etc/tor /usr/local/etc/tor
COPY --from=builder /etc/ssl /etc/ssl
COPY --from=builder /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
COPY --from=builder /lib/libevent-2.1.so.6 /lib/libevent-2.1.so.6
COPY --from=builder /lib/libssl.so.1.1 /lib/libssl.so.1.1
COPY --from=builder /lib/libcrypto.so.1.1 /lib/libcrypto.so.1.1
COPY --from=builder /lib/libz.so.1 /lib/libz.so.1
COPY --from=builder /lib/libgcc_s.so.1 /lib/libgcc_s.so.1
COPY --from=builder /lib/libc.musl-x86_64.so.1 /lib/libc.musl-x86_64.so.1
# 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