1+ FROM debian:bookworm-slim as download
2+
3+ RUN set -ex \
4+ && apt-get update \
5+ && apt-get install -qq --no-install-recommends ca-certificates dirmngr wget \
6+ qemu-user-static binfmt-support
7+
8+ WORKDIR /tmp/bin
9+ RUN wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.13/gosu-armhf" \
10+ && echo "33e421b84b3f746e7353ac2e7c9f199c5beef5a3b2b7a013b591a9af25d84919 gosu" | sha256sum -c -
11+
12+ FROM debian:bookworm-slim as tor-build
13+
14+ ENV TOR_VERSION=0.4.8.10
15+ ENV TOR_HASH=e628b4fab70edb4727715b23cf2931375a9f7685ac08f2c59ea498a178463a86
16+
17+ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates perl autoconf automake build-essential git libtool python3 wget gnupg dirmngr git pkg-config \
18+ libc6-armhf-cross gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
19+
20+ ENV target_host=arm-linux-gnueabihf
21+
22+ ENV AR=${target_host}-ar \
23+ AS=${target_host}-as \
24+ CC=${target_host}-gcc \
25+ CXX=${target_host}-g++ \
26+ LD=${target_host}-ld \
27+ STRIP=${target_host}-strip \
28+ QEMU_LD_PREFIX=/usr/${target_host} \
29+ HOST=${target_host}
30+
31+ # See dependency versions on https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/blob/main/projects
32+
33+ RUN wget -q https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz \
34+ && TAR_NAME=zlib-1.3.tar.gz \
35+ && FOLDER_NAME=zlib-1.3 \
36+ && echo "ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e $TAR_NAME" | sha256sum -c - \
37+ && tar xvf $TAR_NAME \
38+ && cd $FOLDER_NAME \
39+ && ./configure --prefix=$QEMU_LD_PREFIX \
40+ && make \
41+ && make install && cd .. && rm $TAR_NAME && rm -rf $FOLDER_NAME
42+
43+ RUN wget -q https://github.com/openssl/openssl/releases/download/openssl-3.0.12/openssl-3.0.12.tar.gz \
44+ && TAR_NAME=openssl-3.0.12.tar.gz \
45+ && FOLDER_NAME=openssl-3.0.12 \
46+ && echo "f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61 $TAR_NAME" | sha256sum -c - \
47+ && tar xvf $TAR_NAME \
48+ && cd $FOLDER_NAME \
49+ && ./Configure --prefix=$QEMU_LD_PREFIX linux-armv4 -march=armv7+fp no-dso no-zlib no-asm \
50+ && make \
51+ && make install && cd .. && rm $TAR_NAME && rm -rf $FOLDER_NAME
52+
53+ RUN wget -q https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz \
54+ && TAR_NAME=libevent-2.1.12-stable.tar.gz \
55+ && FOLDER_NAME=libevent-2.1.12-stable \
56+ && echo "92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb $TAR_NAME" | sha256sum -c - \
57+ && tar xvf $TAR_NAME \
58+ && cd $FOLDER_NAME \
59+ && ./autogen.sh \
60+ && ./configure --prefix=$QEMU_LD_PREFIX --host=${target_host} --with-pic --disable-samples --disable-libevent-regress \
61+ && make \
62+ && make install && cd .. && rm $TAR_NAME && rm -rf $FOLDER_NAME
63+
64+ # https://trac.torproject.org/projects/tor/ticket/27802
65+ RUN wget -q https://dist.torproject.org/tor-${TOR_VERSION}.tar.gz \
66+ && TAR_NAME=tor-${TOR_VERSION}.tar.gz \
67+ && FOLDER_NAME=tor-${TOR_VERSION} \
68+ && echo "${TOR_HASH} $TAR_NAME" | sha256sum -c - \
69+ && tar xvf $TAR_NAME \
70+ && cd $FOLDER_NAME \
71+ && ./configure --prefix=$QEMU_LD_PREFIX --host=${target_host} --disable-gcc-hardening --disable-asciidoc \
72+ --disable-zstd --disable-lzma \
73+ --with-libevent-dir="$QEMU_LD_PREFIX" \
74+ --with-openssl-dir="$QEMU_LD_PREFIX" \
75+ --with-zlib-dir="$QEMU_LD_PREFIX" \
76+ --disable-systemd --disable-seccomp --disable-unittests --disable-tool-name-check \
77+ --sysconfdir=/usr/local/etc \
78+ && make \
79+ && make install && cd .. && rm $TAR_NAME && rm -rf $FOLDER_NAME \
80+ && ${STRIP} /usr/arm-linux-gnueabihf/bin/tor-* && ${STRIP} /usr/arm-linux-gnueabihf/bin/tor
81+
82+ FROM arm32v7/debian:bookworm-slim
83+ ENV target_host=arm-linux-gnueabihf
84+ ENV QEMU_LD_PREFIX=/usr/${target_host}
85+
86+ COPY --from=download /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
87+ COPY --from=download "/tmp/bin" /usr/local/bin
88+ COPY --from=tor-build ${QEMU_LD_PREFIX}/bin/tor* /usr/bin/
89+ COPY --from=tor-build ${QEMU_LD_PREFIX} /usr/local/
90+ COPY --from=tor-build ${QEMU_LD_PREFIX}/share/tor/ ${QEMU_LD_PREFIX}/share/tor/
91+
92+ ENV TOR_DATA /home/tor/.tor
93+ RUN chmod +x /usr/local/bin/gosu && groupadd -r tor && useradd -r -m -g tor tor && \
94+ mkdir -p ${TOR_DATA} && chown -R tor:tor "$TOR_DATA" && \
95+ rm -rf /lib/arm-linux-gnueabihf/libz* && ldconfig
96+
97+ VOLUME /home/tor/.tor
98+
99+ COPY docker-entrypoint.sh /entrypoint.sh
100+
101+ # SOCKS5, TOR control
102+ EXPOSE 9050 9051
103+ ENV TOR_CONFIG=/usr/local/etc/tor/torrc
104+
105+ RUN rm -rf /usr/arm-linux-gnueabihf/etc/tor \
106+ && mkdir -p /usr/arm-linux-gnueabihf/etc \
107+ && mkdir -p /usr/local/etc/tor \
108+ && ln -sfn /usr/local/etc/tor /usr/arm-linux-gnueabihf/etc/tor
109+
110+ ENTRYPOINT ["./entrypoint.sh" ]
111+ CMD ["tor" ]
0 commit comments