Skip to content

Commit

Permalink
Use several stages for Tor build
Browse files Browse the repository at this point in the history
  • Loading branch information
pajasevi committed Sep 29, 2024
1 parent f21d70b commit 7e06db3
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions docker/my-dojo/tor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
FROM golang:1.23-bullseye AS builder
FROM debian:bullseye-slim AS torbuilder

ENV TOR_URL https://dist.torproject.org
ENV TOR_MIRROR_URL https://tor.eff.org/dist
ENV TOR_VERSION 0.4.8.12
ENV TOR_GPG_KS_URI hkps://keyserver.ubuntu.com:443
ENV TOR_GPG_KEYS 0xEB5A896A28988BF5 0xC218525819F78451 0x21194EBB165733EA 0x6AFEE6D49E92B601 B74417EDDF22AC9F9E90F49142E86A2A11F48D36 514102454D0A87DB0767A1EBBE6A0531C18A9179

ENV OBFS4_URL https://github.com/Yawning/obfs4.git
ENV OBFS4_VERSION 0.0.14

ENV SNOWFLAKE_URL https://git.torproject.org/pluggable-transports/snowflake.git
ENV SNOWFLAKE_VERSION 2.9.2


# Install Tor
RUN set -ex && \
apt-get update && \
Expand Down Expand Up @@ -45,13 +38,31 @@ RUN set -ex && \
--disable-unittests && \
make && make install

FROM golang:1.23-bullseye AS obfs4builder

ENV OBFS4_URL https://github.com/Yawning/obfs4.git
ENV OBFS4_VERSION 0.0.14

RUN set -ex && \
apt-get update && \
apt-get install -y git

# Build OBFS4 proxy
RUN git clone "$OBFS4_URL" /usr/local/src/obfs4proxy && \
cd /usr/local/src/obfs4proxy && \
git checkout "tags/obfs4proxy-$OBFS4_VERSION" && \
go build -o obfs4proxy/obfs4proxy ./obfs4proxy && \
cp ./obfs4proxy/obfs4proxy /usr/local/bin

FROM golang:1.23-bullseye AS snowflakebuilder

ENV SNOWFLAKE_URL https://git.torproject.org/pluggable-transports/snowflake.git
ENV SNOWFLAKE_VERSION 2.9.2

RUN set -ex && \
apt-get update && \
apt-get install -y git

# Build Snowflake proxy
RUN git clone "$SNOWFLAKE_URL" /usr/local/src/snowflake && \
cd /usr/local/src/snowflake && \
Expand All @@ -73,11 +84,11 @@ ENV SNOWFLAKE_PROXY /usr/local/bin/snowflake-client
ARG TOR_LINUX_UID
ARG TOR_LINUX_GID

COPY --from=builder $TOR_BIN $TOR_BIN
COPY --from=builder $TOR_CONF $TOR_CONF
COPY --from=builder $TOR_MAN $TOR_MAN
COPY --from=builder $OBFS_PROXY $OBFS_PROXY
COPY --from=builder $SNOWFLAKE_PROXY $SNOWFLAKE_PROXY
COPY --from=torbuilder $TOR_BIN $TOR_BIN
COPY --from=torbuilder $TOR_CONF $TOR_CONF
COPY --from=torbuilder $TOR_MAN $TOR_MAN
COPY --from=obfs4builder $OBFS_PROXY $OBFS_PROXY
COPY --from=snowflakebuilder $SNOWFLAKE_PROXY $SNOWFLAKE_PROXY

RUN set -ex && \
apt-get update && \
Expand Down

0 comments on commit 7e06db3

Please sign in to comment.