Add docker-compose

This commit is contained in:
Maxim Portnyagin 2022-05-30 18:14:02 +04:00
parent bd6188eeb7
commit b9156bb913
No known key found for this signature in database
GPG Key ID: 8F27C63672B69287
4 changed files with 53 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
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

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

38
docker-compose.yml Normal file
View File

@ -0,0 +1,38 @@
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
volumes:
0net-data:
networks:
0net-network: