Merge 829c8f4f60
into 290025958f
This commit is contained in:
commit
cd06b592c9
5 changed files with 90 additions and 28 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,4 @@
|
||||||
[submodule "plugins"]
|
[submodule "plugins"]
|
||||||
path = plugins
|
path = plugins
|
||||||
url = https://github.com/ZeroNetX/ZeroNet-Plugins.git
|
url = https://github.com/chiva/ZeroNet-Plugins.git
|
||||||
|
branch = lifecycle-updates
|
||||||
|
|
88
Dockerfile
88
Dockerfile
|
@ -1,33 +1,71 @@
|
||||||
FROM alpine:3.15
|
FROM python:3.13-alpine AS builder
|
||||||
|
|
||||||
#Base settings
|
# Set working directory
|
||||||
ENV HOME /root
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt /root/requirements.txt
|
# Copy requirements
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
#Install ZeroNet
|
# Install build dependencies
|
||||||
RUN apk --update --no-cache --no-progress add python3 python3-dev py3-pip gcc g++ autoconf automake libtool libffi-dev musl-dev make tor openssl \
|
RUN apk --no-cache add \
|
||||||
&& pip3 install -r /root/requirements.txt \
|
build-base \
|
||||||
&& apk del python3-dev gcc g++ autoconf automake libtool libffi-dev musl-dev make \
|
git \
|
||||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
autoconf automake libtool \
|
||||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
libffi-dev openssl-dev \
|
||||||
|
musl-dev
|
||||||
RUN python3 -V \
|
|
||||||
&& python3 -m pip list \
|
|
||||||
&& tor --version \
|
|
||||||
&& openssl version
|
|
||||||
|
|
||||||
#Add Zeronet source
|
# Install Python deps
|
||||||
COPY . /root
|
RUN python -m venv /app/venv && \
|
||||||
VOLUME /root/data
|
. /app/venv/bin/activate && \
|
||||||
|
pip install --upgrade pip && \
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
#Control if Tor proxy is started
|
# -----------------------------
|
||||||
ENV ENABLE_TOR true
|
# Runtime image
|
||||||
|
FROM python:3.13-alpine
|
||||||
|
|
||||||
WORKDIR /root
|
# Create app directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
#Set upstart command
|
# Add non-root user
|
||||||
CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26117
|
RUN addgroup -S zeronet && adduser -S -G zeronet zeronet
|
||||||
|
|
||||||
#Expose ports
|
# Install runtime dependencies
|
||||||
EXPOSE 43110 26117
|
RUN apk --no-cache add \
|
||||||
|
tor tini openssl wget
|
||||||
|
|
||||||
|
# Configure tor
|
||||||
|
RUN echo "ControlPort 9051" >> /etc/tor/torrc && \
|
||||||
|
echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||||
|
|
||||||
|
# Copy from builder
|
||||||
|
COPY --from=builder /app/venv /app/venv
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY --chown=zeronet:zeronet . /app
|
||||||
|
|
||||||
|
# Prepare directories
|
||||||
|
RUN mkdir -p /app/data /app/log && \
|
||||||
|
chown -R zeronet:zeronet /app/data /app/log && \
|
||||||
|
chmod 750 /app/data /app/log
|
||||||
|
|
||||||
|
# Set environment
|
||||||
|
ENV PATH="/app/venv/bin:$PATH" \
|
||||||
|
VIRTUAL_ENV="/app/venv" \
|
||||||
|
ENABLE_TOR=true \
|
||||||
|
UI_IP=0.0.0.0 \
|
||||||
|
UI_PORT=43110 \
|
||||||
|
FILESERVER_PORT=26117 \
|
||||||
|
ADDITIONAL_ARGS=""
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER zeronet
|
||||||
|
|
||||||
|
# Use Tini as init to handle signals gracefully
|
||||||
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
|
|
||||||
|
# The command the container runs with
|
||||||
|
CMD ["sh", "-c", "(! ${ENABLE_TOR} || tor&) && python zeronet.py --ui_ip ${UI_IP} --ui_port ${UI_PORT} --fileserver_port ${FILESERVER_PORT} ${ADDITIONAL_ARGS}"]
|
||||||
|
|
||||||
|
# Expose ports - using the environment variables
|
||||||
|
EXPOSE ${UI_PORT} ${FILESERVER_PORT}
|
||||||
|
|
22
docker-compose.yml
Normal file
22
docker-compose.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
services:
|
||||||
|
zeronet:
|
||||||
|
build: .
|
||||||
|
user: zeronet:zeronet
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
- ./log:/app/log
|
||||||
|
ports:
|
||||||
|
- "${UI_PORT:-43110}:${UI_PORT:-43110}"
|
||||||
|
- "${FILESERVER_PORT:-26117}:${FILESERVER_PORT:-26117}"
|
||||||
|
environment:
|
||||||
|
- ENABLE_TOR=true
|
||||||
|
- UI_IP=0.0.0.0
|
||||||
|
- UI_PORT=43110
|
||||||
|
- FILESERVER_PORT=26117
|
||||||
|
- ADDITIONAL_ARGS=
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:${UI_PORT:-43110}/ZeroNet-Internal/Stats", "||", "exit", "1"]
|
||||||
|
interval: 1m
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 30s
|
|
@ -90,7 +90,7 @@ def pow2(x, p):
|
||||||
|
|
||||||
|
|
||||||
def inv(z):
|
def inv(z):
|
||||||
"""$= z^{-1} \mod q$, for z != 0"""
|
"""$= z^{-1} \\mod q$, for z != 0"""
|
||||||
# Adapted from curve25519_athlon.c in djb's Curve25519.
|
# Adapted from curve25519_athlon.c in djb's Curve25519.
|
||||||
z2 = z * z % q # 2
|
z2 = z * z % q # 2
|
||||||
z9 = pow2(z2, 2) * z % q # 9
|
z9 = pow2(z2, 2) * z % q # 9
|
||||||
|
|
|
@ -209,7 +209,8 @@ def httpRequest(url, as_file=False):
|
||||||
|
|
||||||
conn = http.client.HTTPSConnection(host)
|
conn = http.client.HTTPSConnection(host)
|
||||||
sock = socket.create_connection((conn.host, conn.port), conn.timeout, conn.source_address)
|
sock = socket.create_connection((conn.host, conn.port), conn.timeout, conn.source_address)
|
||||||
conn.sock = ssl.wrap_socket(sock, conn.key_file, conn.cert_file)
|
context = ssl.create_default_context()
|
||||||
|
conn.sock = context.wrap_socket(sock, server_hostname=conn.host)
|
||||||
conn.request("GET", request)
|
conn.request("GET", request)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
if response.status in [301, 302, 303, 307, 308]:
|
if response.status in [301, 302, 303, 307, 308]:
|
||||||
|
|
Loading…
Reference in a new issue