Initial changes to support docker-compose

This commit is contained in:
Ben Wilson 2019-09-25 13:29:08 -04:00
parent a24b0d8d05
commit feb0ee8906
9 changed files with 129 additions and 6 deletions

7
.env-example Normal file
View File

@ -0,0 +1,7 @@
POSTGRES_PASSWORD=notsecure
POSTGRES_HOST=db
ENVIRONMENT=dev
RPCUSER=zcashrpc
RPCPASSWORD=notsecure
ZCASHD_DATADIR=/tmp/.zcash
ZCASHD_PARMDIR=/tmp/.zcash-params

3
.gitignore vendored
View File

@ -90,3 +90,6 @@ ENV/
*.sqlite3
.vscode
.docker
.env

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python:2
ENV PYTHONUNBUFFERED 1
WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt && \
pip install -r requirements-prod.txt
#ENTRYPOINT ["docker/zfaucet/entrypoint.sh"]

52
docker-compose.yml Normal file
View File

@ -0,0 +1,52 @@
---
version: '3'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_USER: django
ports:
- "5432:5432"
nginx:
image: nginx
ports:
- "8080:80"
volumes:
- ./docker/nginx/zfaucet.conf:/etc/nginx/conf.d/default.conf
- static_volume:/usr/share/nginx/html/static
depends_on:
- zfaucet
zfaucet:
build: .
#command: python manage.py runserver 0.0.0.0:8000
command: gunicorn --bind=0.0.0.0:8000 --workers=2 zfaucet.wsgi
ports:
- "8000:8000"
depends_on:
- db
- zcashd
volumes:
- .:/app
- static_volume:/home/zcashd/zfaucet/faucet/static
environment:
DJANGO_ENVIRONMENT: $ENVIRONMENT
DJANGO_POSTGRESQL_PASSWORD: $POSTGRES_PASSWORD
DJANGO_POSTGRESQL_USER: django
DJANGO_POSTGRESQL_HOST: $POSTGRES_HOST
RPCUSER: $RPCUSER
RPCPASSWORD: $RPCPASSWORD
ZCASH_NETWORK: http://zcashd:18232
zcashd:
build:
context: docker/zcashd
command: zcashd
ports:
- "18232:18232"
volumes:
- $ZCASHD_DATADIR:/home/zcashd/.zcash
- $ZCASHD_PARMDIR:/home/zcashd/.zcash-params
volumes:
static_volume:

20
docker/nginx/zfaucet.conf Normal file
View File

@ -0,0 +1,20 @@
server {
listen 80;
server_name localhost;
access_log off;
location /static/ {
root /usr/share/nginx/html;
}
location / {
proxy_pass http://zfaucet:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}

19
docker/zcashd/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM debian:9
RUN apt-get update \
&& apt-get install -y gnupg2 apt-transport-https curl
ARG ZCASH_SIGNING_KEY_ID=6DEF3BAF272766C0
ARG ZCASH_VERSION=2.0.7+2
ARG ZCASHD_USER=zcashd
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $ZCASH_SIGNING_KEY_ID \
&& echo "deb [arch=amd64] https://apt.z.cash/ jessie main" > /etc/apt/sources.list.d/zcash.list \
&& apt-get update \
&& apt-get install -y zcash=$ZCASH_VERSION
RUN adduser --quiet $ZCASHD_USER
ADD zcash.conf /home/$ZCASHD_USER/.zcash/zcash.conf
RUN chown -R $ZCASHD_USER:$ZCASHD_USER /home/$ZCASHD_USER
USER zcashd
WORKDIR /home/zcashd

11
docker/zcashd/zcash.conf Normal file
View File

@ -0,0 +1,11 @@
listen=1
showmetrics=0
logips=1
testnet=1
gen=1
addnode=testnet.z.cash
experimentalfeatures=1
zshieldcoinbase=1
maxconnections=1000
rpcuser=zcashrpc
rpcpassword=295c0dea2d014e0c29d140a077a86b3b

View File

@ -35,7 +35,7 @@ def index(request):
difficulty = '0'
height = '0'
zd = ZDaemon()
zd = ZDaemon(network=ZCASH_NETWORK)
version = zd.getVersion()
#If it is a post, an address was submitted.

View File

@ -30,9 +30,11 @@ print 'settings environment is ' + ENVIRONMENT
#else:
# These secrets are written by Ansible during provisioning.
SECRET_KEY = ''
DJANGO_POSTGRESQL_PASSWORD = ''
SECRET_KEY = os.getenv('SECRET_KEY', 'badsecret')
DJANGO_POSTGRESQL_USER = os.getenv('DJANGO_POSTGRESQL_USER', 'django')
DJANGO_POSTGRESQL_PASSWORD = os.getenv('DJANGO_POSTGRESQL_PASSWORD', '')
DJANGO_POSTGRESQL_HOST = os.getenv('DJANGO_POSTGRESQL_HOST', 'localhost')
ZCASH_NETWORK = os.getenv('ZCASH_NETWORK', 'http://localhost:18232')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = ENVIRONMENT == 'dev'
@ -102,9 +104,9 @@ else:
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'django',
'USER': DJANGO_POSTGRESQL_USER,
'PASSWORD': DJANGO_POSTGRESQL_PASSWORD,
'HOST': '127.0.0.1',
'HOST': DJANGO_POSTGRESQL_HOST,
'PORT': '5432',
'CONN_MAX_AGE': 3600,
},