Merge pull request #97 from prtngn/master

Add docker-compose and docker documentation (en/ru)

fixes #70
This commit is contained in:
caryoscelus 2022-05-31 20:33:30 +04:00 committed by GitHub
commit 1a0b079bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 100 additions and 43 deletions

View File

@ -1,21 +1,17 @@
FROM python:3.10.4-alpine
RUN apk --update --no-cache --no-progress add gcc libffi-dev musl-dev make tor openssl g++ \
&& echo "ControlPort 9051" >> /etc/tor/torrc \
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
RUN apk --update --no-cache --no-progress add gcc libffi-dev musl-dev make openssl g++
WORKDIR /app
VOLUME /app/data
COPY . .
RUN python3 -m venv venv \
&& source venv/bin/activate \
&& python3 -m pip install -r requirements.txt
ENV ENABLE_TOR false
CMD (! ${ENABLE_TOR} || tor&) \
&& source venv/bin/activate \
&& python3 zeronet.py --ui_ip "*" --fileserver_port 26552
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

View File

@ -1,34 +0,0 @@
FROM alpine:3.12
#Base settings
ENV HOME /root
COPY requirements.txt /root/requirements.txt
#Install ZeroNet
RUN apk --update --no-cache --no-progress add python3 python3-dev gcc libffi-dev musl-dev make tor openssl \
&& pip3 install -r /root/requirements.txt \
&& apk del python3-dev gcc libffi-dev musl-dev make \
&& echo "ControlPort 9051" >> /etc/tor/torrc \
&& echo "CookieAuthentication 1" >> /etc/tor/torrc
RUN python3 -V \
&& python3 -m pip list \
&& tor --version \
&& openssl version
#Add Zeronet source
COPY . /root
VOLUME /root/data
#Control if Tor proxy is started
ENV ENABLE_TOR false
WORKDIR /root
#Set upstart command
CMD (! ${ENABLE_TOR} || tor&) && python3 zeronet.py --ui_ip 0.0.0.0 --fileserver_port 26552
#Expose ports
EXPOSE 43110 26552

18
Dockerfile.integrated_tor Normal file
View File

@ -0,0 +1,18 @@
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

10
Dockerfile.tor Normal file
View File

@ -0,0 +1,10 @@
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

View File

@ -90,6 +90,14 @@ zeronet-conservancy — это форк/продолжение проекта [Z
- `source venv/bin/activate`
- `python3 zeronet.py`
#### Создание образа Docker
- создание образа: `docker build -t 0net:conservancy . -f Dockerfile`
- или создрание образа с встроенным tor: `docker build -t 0net:conservancy . -f Dockerfile.integrated_tor`
- и его запуск: `docker run --rm -it -v </path/to/0n/data/directory>:/app/data -p 43110:43110 -p 26552:26552 0net:conservancy`
- /path/to/0n/data/directory - директория, куда будут сохраняться все данные в том числе секретные ключи. Если вы запускаете в боевом режиме, не потеряйте эту папку!
- или вы можете воспользоваться docker-compose: `docker compose up -d 0net` запускает два контейнера раздельно, для 0net и tor сервисов.
- или: `docker compose up -d 0net-tor` запускает один контейнер с tor и 0net.
#### альтернативный скрипт
- после установки общих зависимостей и клонирования репозитория (как указано выше) запустите `start-venv.sh` который создаст для вас виртуальную среду и установит требования Python
- больше удобных скриптов будует добавлено в ближайшее время

View File

@ -90,6 +90,14 @@ Install autoconf and other basic development tools, python3 and pip.
- `source venv/bin/activate`
- `python3 zeronet.py`
#### Build Docker image
- build 0net image: `docker build -t 0net:conservancy . -f Dockerfile`
- or build 0net image with integrated tor: `docker build -t 0net:conservancy . -f Dockerfile.integrated_tor`
- and run it: `docker run --rm -it -v </path/to/0n/data/directory>:/app/data -p 43110:43110 -p 26552:26552 0net:conservancy`
- /path/to/0n/data/directory - directory, where all data will be saved, including your secret certificates. If you run it with production mode, do not remove this folder!
- or you can run it with docker-compose: `docker compose up -d 0net` up two containers - 0net and tor separately.
- or: `docker compose up -d 0net-tor` for run 0net and tor in one container.
#### alternative script
- after installing general dependencies and cloning repo (as above), run `start-venv.sh` which will create a virtual env for you and install python requirements
- more convenience scripts to be added soon

51
docker-compose.yml Normal file
View File

@ -0,0 +1,51 @@
version: '3'
services:
tor:
tty: true
stdin_open: true
build:
context: .
dockerfile: Dockerfile.tor
networks:
- 0net-network
ports:
- "9050:9050"
- "9051:9051"
environment: &tor-environments
TOR_CONTROL_PASSWD: some_password
TOR_SOCKS_PORT: 9050
TOR_CONTROL_PORT: 9051
0net:
tty: true
stdin_open: true
build:
context: .
networks:
- 0net-network
volumes:
- 0net-data:/app/data
ports:
- "26552:26552"
- "43110:43110"
depends_on:
- tor
environment:
TOR_ENABLED: enable
<<: *tor-environments
0net-tor:
tty: true
stdin_open: true
build:
context: .
dockerfile: Dockerfile.integrated_tor
networks:
- 0net-network
volumes:
- 0net-data:/app/data
ports:
- "26552:26552"
- "43110:43110"
volumes:
0net-data:
networks:
0net-network: