mirror of
https://github.com/oldnick85/tor_yggdrasil_docker.git
synced 2025-11-29 03:13:44 +01:00
[ref] some improvements
This commit is contained in:
+64
-38
@@ -1,63 +1,89 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
ARG UBUNTU_VERSION=24.04
|
||||
|
||||
# === STAGE 1: Build Yggdrasil from source ===
|
||||
FROM ubuntu:${UBUNTU_VERSION} as builder_yggdrasil
|
||||
ARG YGGDRASIL_VERSION=v0.5.12
|
||||
RUN DEBIAN_FRONTEND=noninteractive\
|
||||
apt-get update &&\
|
||||
apt-get -y upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive\
|
||||
apt-get install -y git golang
|
||||
|
||||
# Install build dependencies
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
git golang ca-certificates && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Clone and build Yggdrasil from official repository
|
||||
WORKDIR /BUILD_YGGDRASIL/
|
||||
RUN git clone --depth 1 --branch $YGGDRASIL_VERSION https://github.com/yggdrasil-network/yggdrasil-go.git
|
||||
ENV CGO_ENABLED=0
|
||||
RUN git clone --depth 1 --branch $YGGDRASIL_VERSION \
|
||||
https://github.com/yggdrasil-network/yggdrasil-go.git
|
||||
|
||||
# Build Yggdrasil with static linking for better portability
|
||||
WORKDIR /BUILD_YGGDRASIL/yggdrasil-go
|
||||
# add genkeys to build
|
||||
RUN sed -i -e 's/yggdrasil yggdrasilctl/yggdrasil yggdrasilctl genkeys/g' build
|
||||
RUN ./build
|
||||
|
||||
# === STAGE 2: Runtime environment ===
|
||||
FROM ubuntu:${UBUNTU_VERSION}
|
||||
RUN DEBIAN_FRONTEND=noninteractive\
|
||||
apt-get update &&\
|
||||
apt-get -y upgrade
|
||||
RUN DEBIAN_FRONTEND=noninteractive\
|
||||
apt-get install -y --fix-missing\
|
||||
tor obfs4proxy\
|
||||
git python3 python3-pip iputils-ping
|
||||
# ==== UTILS ====
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
# Tor and related services
|
||||
tor obfs4proxy \
|
||||
# Utilities and scripting
|
||||
git python3 python3-pip iputils-ping curl && \
|
||||
# Clear
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# === UTILITIES SECTION ===
|
||||
WORKDIR /UTILS/
|
||||
RUN git config --global advice.detachedHead false
|
||||
# script to get strong yggdrasil address (https://yggdrasil-network.github.io/configuration.html#generating-stronger-addresses-and-prefixes)
|
||||
RUN git clone --depth 1 --branch v0 https://github.com/oldnick85/yggdrasil_get_keys.git /UTILS/yggdrasil_get_keys
|
||||
RUN python3 -m pip install --break-system-packages -r /UTILS/yggdrasil_get_keys/requirements.txt
|
||||
# script to find yggdrasil public peers
|
||||
RUN git clone --depth 1 --branch v4 https://github.com/oldnick85/yggdrasil_find_public_peers.git /UTILS/yggdrasil_find_public_peers
|
||||
RUN python3 -m pip install --break-system-packages -r /UTILS/yggdrasil_find_public_peers/requirements.txt
|
||||
# save peers to use in case of unavailable repository
|
||||
# Clone key generation script for strong Yggdrasil address (https://yggdrasil-network.github.io/configuration.html#generating-stronger-addresses-and-prefixes)
|
||||
RUN git clone --depth 1 --branch v0 \
|
||||
https://github.com/oldnick85/yggdrasil_get_keys.git \
|
||||
/UTILS/yggdrasil_get_keys
|
||||
|
||||
# Clone peer discovery script for finding public Yggdrasil peers
|
||||
RUN git clone --depth 1 --branch v4 \
|
||||
https://github.com/oldnick85/yggdrasil_find_public_peers.git \
|
||||
/UTILS/yggdrasil_find_public_peers
|
||||
|
||||
# Install Python dependencies
|
||||
RUN python3 -m pip install --break-system-packages \
|
||||
-r /UTILS/yggdrasil_get_keys/requirements.txt && \
|
||||
python3 -m pip install --break-system-packages \
|
||||
-r /UTILS/yggdrasil_find_public_peers/requirements.txt
|
||||
|
||||
# Pre-fetch public peers list as fallback in case repository is unavailable
|
||||
RUN python3 /UTILS/yggdrasil_find_public_peers/yggdrasil_find_public_peers.py \
|
||||
--yggdrasil-conf="" \
|
||||
--yggdrasil-peers-json="/UTILS/yggdrasil_find_public_peers/public_peers.json"
|
||||
--yggdrasil-conf="" \
|
||||
--yggdrasil-peers-json="/UTILS/yggdrasil_find_public_peers/public_peers.json"
|
||||
# ==== YGGDRASIL ====
|
||||
# Ports used by YGGDRASIL
|
||||
# Listen
|
||||
EXPOSE 10654
|
||||
# Default yggdrasil port
|
||||
EXPOSE 9001
|
||||
WORKDIR /YGGDRASIL/
|
||||
# Copy built binaries from builder stage
|
||||
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/yggdrasil .
|
||||
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/yggdrasilctl .
|
||||
COPY --from=builder_yggdrasil /BUILD_YGGDRASIL/yggdrasil-go/genkeys .
|
||||
COPY ./yggdrasil.conf .
|
||||
# ==== TOR ====
|
||||
# Base configuration file
|
||||
COPY ./yggdrasil.conf .
|
||||
|
||||
# === TOR PROXY SETUP ===
|
||||
# SOCKS5 proxy port
|
||||
EXPOSE 9050
|
||||
EXPOSE 8118
|
||||
WORKDIR /tmp/
|
||||
COPY ./torrc /etc/tor
|
||||
RUN ls /etc/tor
|
||||
EXPOSE 8118
|
||||
# Tor configuration
|
||||
COPY ./torrc /etc/tor/torrc
|
||||
COPY ./tor /etc/default/tor
|
||||
RUN chmod -R 0700 /etc/default/tor
|
||||
RUN cat /etc/default/tor
|
||||
RUN cat /etc/tor/torrc
|
||||
WORKDIR /
|
||||
COPY ./entrypoint.sh .
|
||||
ENTRYPOINT ["bash", "/entrypoint.sh"]
|
||||
# === CONTAINER STARTUP ===
|
||||
COPY ./entrypoint.sh /entrypoint.sh
|
||||
# Make entrypoint executable
|
||||
RUN chmod +x /entrypoint.sh
|
||||
# Default container command
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
Reference in New Issue
Block a user