FROM python:3.11-alpine ENV HOME=/var/lib/tor ENV VANGUARDS_CONFIG=/etc/tor/vanguards.conf # Install runtime dependencies # tor and torsocks are available in Alpine edge/community repos RUN apk add --no-cache \ tor \ torsocks \ libevent \ openssl \ ca-certificates \ libffi \ && mkdir -p /var/lib/tor/hidden_service/ \ && chown -R tor:root /var/lib/tor WORKDIR /usr/local/src/onions # Install Python dependencies COPY requirements.txt . RUN apk add --no-cache --virtual .build-deps \ build-base \ openssl-dev \ libffi-dev \ cargo \ && pip install --no-cache-dir -r requirements.txt \ && apk del .build-deps # Install application COPY setup.py . COPY onions onions/ RUN pip install --no-cache-dir . # Copy configuration and entrypoint COPY assets/entrypoint-config.yml /entrypoint-config.yml COPY assets/torrc /var/local/tor/torrc.tpl COPY assets/vanguards.conf.tpl /var/local/tor/vanguards.conf.tpl COPY assets/entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh VOLUME ["/var/lib/tor/hidden_service/"] ENTRYPOINT ["/entrypoint.sh"] CMD ["tor"]