Merge pull request #243 from caryoscelus/docker-update
Docker update & minor improvements
This commit is contained in:
commit
28440346b1
15 changed files with 139 additions and 84 deletions
|
@ -1,3 +1,5 @@
|
|||
venv
|
||||
Dockerfile*
|
||||
docker
|
||||
data
|
||||
__pycahce__
|
||||
log
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -19,6 +19,7 @@ __pycache__/
|
|||
|
||||
# Data dir
|
||||
data/*
|
||||
docker/data/
|
||||
*.db
|
||||
|
||||
# Virtualenv
|
||||
|
|
17
Dockerfile
17
Dockerfile
|
@ -1,17 +0,0 @@
|
|||
FROM python:3.10.4-alpine
|
||||
|
||||
RUN apk --update --no-cache --no-progress add gcc libffi-dev musl-dev make openssl g++
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
RUN python3 -m venv venv \
|
||||
&& source venv/bin/activate \
|
||||
&& python3 -m pip install -r requirements.txt
|
||||
|
||||
CMD source venv/bin/activate \
|
||||
&& python3 zeronet.py --ui_ip "*" --fileserver_port 26552 \
|
||||
--tor $TOR_ENABLED --tor_controller tor:$TOR_CONTROL_PORT \
|
||||
--tor_proxy tor:$TOR_SOCKS_PORT --tor_password $TOR_CONTROL_PASSWD main
|
||||
|
||||
EXPOSE 43110 26552
|
|
@ -1,18 +0,0 @@
|
|||
FROM python:3.10.4-alpine
|
||||
|
||||
RUN apk --update --no-cache --no-progress add tor gcc libffi-dev musl-dev make openssl g++ \
|
||||
&& echo "ControlPort 9051" >> /etc/tor/torrc \
|
||||
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
RUN python3 -m venv venv \
|
||||
&& source venv/bin/activate \
|
||||
&& python3 -m pip install -r requirements.txt
|
||||
|
||||
CMD (tor&) \
|
||||
&& source venv/bin/activate \
|
||||
&& python3 zeronet.py --ui_ip "*" --fileserver_port 26552
|
||||
|
||||
EXPOSE 43110 26552
|
|
@ -1,10 +0,0 @@
|
|||
FROM alpine:3.16.0
|
||||
|
||||
RUN apk --update --no-cache --no-progress add tor
|
||||
|
||||
CMD hashed_control_password=$(tor --quiet --hash-password $TOR_CONTROL_PASSWD) \
|
||||
&& tor --SocksPort 0.0.0.0:$TOR_SOCKS_PORT \
|
||||
--ControlPort 0.0.0.0:$TOR_CONTROL_PORT \
|
||||
--HashedControlPassword $hashed_control_password
|
||||
|
||||
EXPOSE $TOR_SOCKS_PORT $TOR_CONTROL_PORT
|
|
@ -97,7 +97,7 @@ Install autoconf and other basic development tools, python3 and pip, then procee
|
|||
|
||||
##### Apt-based (debian, ubuntu, etc)
|
||||
- `sudo apt update`
|
||||
- `sudo apt install pkg-config libffi-dev python3-pip python3-venv python3-dev build-essential`
|
||||
- `sudo apt install git pkg-config libffi-dev python3-pip python3-venv python3-dev build-essential libtool`
|
||||
|
||||
##### Red Hat and Fedora based
|
||||
- `yum install epel-release -y 2>/dev/null`
|
||||
|
|
25
docker/Dockerfile
Normal file
25
docker/Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
|||
FROM python:3.12-alpine
|
||||
|
||||
RUN apk --update --no-cache --no-progress add git gcc libffi-dev musl-dev make openssl g++ autoconf automake libtool
|
||||
|
||||
RUN adduser -u 1600 -D service-0net
|
||||
|
||||
USER service-0net:service-0net
|
||||
|
||||
WORKDIR /home/service-0net
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN python3 -m pip install -r requirements.txt
|
||||
|
||||
# the part below is updated with source updates
|
||||
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT python3 zeronet.py --ui_ip "*" --fileserver_port 26552 \
|
||||
--tor $TOR_ENABLED --tor_controller tor:$TOR_CONTROL_PORT \
|
||||
--tor_proxy tor:$TOR_SOCKS_PORT --tor_password $TOR_CONTROL_PASSWD
|
||||
|
||||
CMD main
|
||||
|
||||
EXPOSE 43110 26552
|
26
docker/debian.Dockerfile
Normal file
26
docker/debian.Dockerfile
Normal file
|
@ -0,0 +1,26 @@
|
|||
FROM python:3.12-slim-bookworm
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git openssl pkg-config libffi-dev python3-pip python3-dev build-essential libtool
|
||||
|
||||
RUN useradd -u 1600 -m service-0net
|
||||
|
||||
USER service-0net:service-0net
|
||||
|
||||
WORKDIR /home/service-0net
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN python3 -m pip install -r requirements.txt
|
||||
|
||||
# the part below is updated with source updates
|
||||
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT python3 zeronet.py --ui_ip "*" --fileserver_port 26552 \
|
||||
--tor $TOR_ENABLED --tor_controller tor:$TOR_CONTROL_PORT \
|
||||
--tor_proxy tor:$TOR_SOCKS_PORT --tor_password $TOR_CONTROL_PASSWD
|
||||
|
||||
CMD main
|
||||
|
||||
EXPOSE 43110 26552
|
|
@ -1,51 +1,55 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
tor:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.tor
|
||||
context: ..
|
||||
dockerfile: docker/tor.Dockerfile
|
||||
networks:
|
||||
- 0net-network
|
||||
ports:
|
||||
- "9050:9050"
|
||||
- "9051:9051"
|
||||
environment: &tor-environments
|
||||
# since we are using tor internally, password doesn't really matter
|
||||
TOR_CONTROL_PASSWD: some_password
|
||||
TOR_SOCKS_PORT: 9050
|
||||
TOR_CONTROL_PORT: 9051
|
||||
0net:
|
||||
|
||||
0net-conservancy:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
build:
|
||||
context: .
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
networks:
|
||||
- 0net-network
|
||||
volumes:
|
||||
- 0net-data:/app/data
|
||||
# NOTE: this refers to docker/data..
|
||||
- ./data:/home/service-0net/data
|
||||
ports:
|
||||
- "26552:26552"
|
||||
- "43110:43110"
|
||||
- "127.0.0.1:43110:43110"
|
||||
depends_on:
|
||||
- tor
|
||||
environment:
|
||||
TOR_ENABLED: enable
|
||||
<<: *tor-environments
|
||||
|
||||
# integrated container with tor
|
||||
0net-tor:
|
||||
tty: true
|
||||
stdin_open: true
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.integrated_tor
|
||||
context: ..
|
||||
dockerfile: docker/znctor.Dockerfile
|
||||
networks:
|
||||
- 0net-network
|
||||
volumes:
|
||||
- 0net-data:/app/data
|
||||
# NOTE: this refers to docker/data..
|
||||
- ./data:/home/service-0net/data
|
||||
ports:
|
||||
- "26552:26552"
|
||||
- "43110:43110"
|
||||
volumes:
|
||||
0net-data:
|
||||
- "127.0.0.1:43110:43110"
|
||||
|
||||
networks:
|
||||
0net-network:
|
9
docker/tor.Dockerfile
Normal file
9
docker/tor.Dockerfile
Normal file
|
@ -0,0 +1,9 @@
|
|||
FROM alpine:3.18
|
||||
|
||||
RUN apk --update --no-cache --no-progress add tor
|
||||
|
||||
USER tor
|
||||
|
||||
CMD tor --SocksPort 0.0.0.0:${TOR_SOCKS_PORT} --ControlPort 0.0.0.0:${TOR_CONTROL_PORT} --HashedControlPassword $(tor --quiet --hash-password $TOR_CONTROL_PASSWD)
|
||||
|
||||
EXPOSE $TOR_SOCKS_PORT $TOR_CONTROL_PORT
|
31
docker/znctor.Dockerfile
Normal file
31
docker/znctor.Dockerfile
Normal file
|
@ -0,0 +1,31 @@
|
|||
FROM python:3.12-alpine
|
||||
|
||||
RUN apk --update --no-cache --no-progress add git gcc libffi-dev musl-dev make openssl g++ autoconf automake libtool
|
||||
RUN apk add tor
|
||||
|
||||
RUN echo "ControlPort 9051" >> /etc/tor/torrc
|
||||
RUN echo "CookieAuthentication 1" >> /etc/tor/torrc
|
||||
|
||||
RUN adduser -u 1600 -D service-0net
|
||||
|
||||
USER service-0net:service-0net
|
||||
|
||||
WORKDIR /home/service-0net
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN python3 -m pip install -r requirements.txt
|
||||
|
||||
RUN echo "tor &" > start.sh
|
||||
RUN echo "python3 zeronet.py --ui_ip '*' --fileserver_port 26552" >> start.sh
|
||||
RUN chmod +x start.sh
|
||||
|
||||
# the part below is updated with source updates
|
||||
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT ./start.sh
|
||||
|
||||
CMD main
|
||||
|
||||
EXPOSE 43110 26552
|
2
greet.py
2
greet.py
|
@ -18,7 +18,7 @@ def grad(n):
|
|||
def fancy_greet(version):
|
||||
from rich.console import Console
|
||||
from rich.text import Text
|
||||
zc_msg = f'''
|
||||
zc_msg = fr'''
|
||||
||| . . _ _._|_ _. . . _ .__ _.. _. . __.. _ __. .
|
||||
||| //\|/ |/_| | == / / \|/ |( /_||/ | | __||/ |/ \_|
|
||||
||| \_/| |\_ |. \__\_/| |_) \_ | \/ |__|| |\__ _/
|
||||
|
|
|
@ -45,7 +45,7 @@ class UiRequestPlugin(object):
|
|||
file_obj = None
|
||||
path_parts = self.parsePath(path)
|
||||
file_path = "%s/%s/%s" % (config.data_dir, path_parts["address"], path_parts["inner_path"])
|
||||
match = re.match("^(.*\.(?:tar.gz|zip))/(.*)", file_path)
|
||||
match = re.match(r"^(.*\.(?:tar.gz|zip))/(.*)", file_path)
|
||||
archive_path, path_within = match.groups()
|
||||
if archive_path not in archive_cache:
|
||||
site = self.server.site_manager.get(path_parts["address"])
|
||||
|
@ -99,7 +99,7 @@ class UiRequestPlugin(object):
|
|||
class SiteStoragePlugin(object):
|
||||
def isFile(self, inner_path):
|
||||
if ".zip/" in inner_path or ".tar.gz/" in inner_path:
|
||||
match = re.match("^(.*\.(?:tar.gz|zip))/(.*)", inner_path)
|
||||
match = re.match(r"^(.*\.(?:tar.gz|zip))/(.*)", inner_path)
|
||||
archive_inner_path, path_within = match.groups()
|
||||
return super(SiteStoragePlugin, self).isFile(archive_inner_path)
|
||||
else:
|
||||
|
@ -127,7 +127,7 @@ class SiteStoragePlugin(object):
|
|||
|
||||
def walk(self, inner_path, *args, **kwags):
|
||||
if ".zip" in inner_path or ".tar.gz" in inner_path:
|
||||
match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
match = re.match(r"^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
archive_inner_path, path_within = match.groups()
|
||||
archive = self.openArchive(archive_inner_path)
|
||||
path_within = path_within.lstrip("/")
|
||||
|
@ -151,7 +151,7 @@ class SiteStoragePlugin(object):
|
|||
|
||||
def list(self, inner_path, *args, **kwags):
|
||||
if ".zip" in inner_path or ".tar.gz" in inner_path:
|
||||
match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
match = re.match(r"^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
archive_inner_path, path_within = match.groups()
|
||||
archive = self.openArchive(archive_inner_path)
|
||||
path_within = path_within.lstrip("/")
|
||||
|
@ -178,7 +178,7 @@ class SiteStoragePlugin(object):
|
|||
|
||||
def read(self, inner_path, mode="rb", **kwargs):
|
||||
if ".zip/" in inner_path or ".tar.gz/" in inner_path:
|
||||
match = re.match("^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
match = re.match(r"^(.*\.(?:tar.gz|zip))(.*)", inner_path)
|
||||
archive_inner_path, path_within = match.groups()
|
||||
archive = self.openArchive(archive_inner_path)
|
||||
path_within = path_within.lstrip("/")
|
||||
|
|
|
@ -64,7 +64,7 @@ def pow2(x, p):
|
|||
|
||||
|
||||
def inv(z):
|
||||
"""$= z^{-1} \mod q$, for z != 0"""
|
||||
r"""$= z^{-1} \mod q$, for z != 0"""
|
||||
# Adapted from curve25519_athlon.c in djb's Curve25519.
|
||||
z2 = z * z % q # 2
|
||||
z9 = pow2(z2, 2) * z % q # 9
|
||||
|
|
|
@ -74,15 +74,17 @@ def importBundle(bundle):
|
|||
|
||||
def init_dirs():
|
||||
data_dir = config.data_dir
|
||||
if not os.path.isdir(data_dir):
|
||||
has_data_dir = os.path.isdir(data_dir)
|
||||
need_bootstrap = not config.disable_bootstrap and (not has_data_dir or not os.path.isfile(f'{data_dir}/sites.json')) and not config.offline
|
||||
|
||||
if not has_data_dir:
|
||||
os.mkdir(data_dir)
|
||||
try:
|
||||
os.chmod(data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
except Exception as err:
|
||||
startupError(f"Can't change permission of {data_dir}: {err}")
|
||||
|
||||
# download latest bootstrap bundle
|
||||
if not config.disable_bootstrap and not config.offline:
|
||||
if need_bootstrap:
|
||||
import requests
|
||||
from io import BytesIO
|
||||
|
||||
|
|
Loading…
Reference in a new issue