Skip to content

Commit d1c1773

Browse files
author
Jamie McCusker
committed
Added built-in support for running from docker for both dev and production deployments.
1 parent c4ee7fc commit d1c1773

7 files changed

Lines changed: 125 additions & 4 deletions

File tree

‎script/build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ echo ${VERSION}
1313
python setup.py build
1414
python setup.py sdist
1515

16-
docker build . --build-arg __version__=${VERSION} -t tetherlessworld/whyis:${VERSION} # -t tetherlessworld/whyis:latest
16+
docker build . --build-arg __version__=${VERSION} -t tetherlessworld/whyis:${VERSION} -t tetherlessworld/whyis:latest
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM tetherlessworld/whyis:latest
2+
RUN apt-get update
3+
COPY . /app
4+
COPY ./install_files/system-docker.conf /app/system.conf
5+
RUN /opt/venv/bin/pip install -r /app/requirements.txt
6+
WORKDIR '/app'
7+
CMD [ "/bin/bash" ]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM tetherlessworld/whyis:latest
2+
COPY ./requirements.txt /requirements.txt
3+
RUN /opt/venv/bin/pip install -r /requirements.txt
4+
WORKDIR '/app'
5+
CMD [ "/opt/venv/bin/whyis", "run", "-h", "0.0.0.0" ]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
whyis-dev:
3+
build:
4+
dockerfile: Dockerfile.dev
5+
context: .
6+
volumes:
7+
- type: bind
8+
source: .
9+
target: /app
10+
ports:
11+
- '5000:5000'
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
services:
2+
redis:
3+
image: "redis:alpine"
4+
command: redis-server
5+
volumes:
6+
- type: bind
7+
source: ./run/redis-data
8+
target: /var/lib/redis
9+
celery:
10+
depends_on:
11+
- redis
12+
- fuseki
13+
command: /opt/venv/bin/celery -A wsgi.celery worker -l INFO -c 4 --uid=nobody --gid=nogroup
14+
volumes:
15+
- type: bind
16+
source: .
17+
target: /data
18+
build:
19+
dockerfile: Dockerfile
20+
context: .
21+
celerybeat:
22+
depends_on:
23+
- redis
24+
- fuseki
25+
command: /opt/venv/bin/celery -A wsgi.celery beat -l INFO --uid=nobody --gid=nogroup
26+
volumes:
27+
- type: bind
28+
source: .
29+
target: /data
30+
build:
31+
dockerfile: Dockerfile
32+
context: .
33+
fuseki:
34+
command: /opt/venv/bin/fuseki-server --mem /ds
35+
build:
36+
dockerfile: Dockerfile
37+
context: .
38+
ports:
39+
- '3030:3030'
40+
volumes:
41+
- type: bind
42+
source: ./run
43+
target: /app/run
44+
whyis:
45+
depends_on:
46+
- redis
47+
- fuseki
48+
stdin_open: true
49+
command: /opt/venv/bin/gunicorn wsgi:application --workers ${WEB_CONCURRENCY:-4} --timeout 90 -b :8000
50+
build:
51+
dockerfile: Dockerfile
52+
context: .
53+
volumes:
54+
- type: bind
55+
source: .
56+
target: /data
57+
ports:
58+
- '8000:8000'
59+
- '5000:5000'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import logging
2+
from datetime import datetime, timedelta
3+
4+
DEBUG=False
5+
6+
# LOGGING
7+
LOGGER_NAME = "whyis_log"
8+
LOG_FILENAME = "/var/log/whyis/output-whyis-%s.log" % (str(datetime.now()).replace(' ','_'))
9+
LOG_LEVEL = logging.INFO
10+
LOG_FORMAT = "%(asctime)s %(levelname)s\t: %(message)s" # used by logging.Formatter
11+
12+
PERMANENT_SESSION_LIFETIME = timedelta(days=7)
13+
# EMAIL CONFIGURATION
14+
## MAIL_SERVER = "smtp.mailgun.org"
15+
## MAIL_PORT = 587
16+
## MAIL_USE_TLS = True
17+
## MAIL_USE_SSL = False
18+
## MAIL_DEBUG = False
19+
## MAIL_USERNAME = ''
20+
## MAIL_PASSWORD = ''
21+
## DEFAULT_MAIL_SENDER = "Whyis Admin <admin@whyis.example.com>"
22+
EMBEDDED_FUSEKI = False
23+
ADMIN_ENDPOINT = 'http://fuseki:3030/admin/sparql'
24+
25+
KNOWLEDGE_ENDPOINT = 'http://fuseki:3030/knowledge/sparql'
26+
27+
EMBEDDED_CELERY = False
28+
CELERY_BROKER_URL = 'redis://redis:6379/0'
29+
CELERY_RESULT_BACKEND = 'redis://redis:6379/0'
30+
31+
NANOPUB_ARCHIVE = {
32+
'depot.storage_path' : "/data/nanopublications",
33+
}
34+
FILE_ARCHIVE = {
35+
'cache_max_age' : 3600*24*7,
36+
'depot.storage_path' : '/data/files'
37+
}
38+
CACHE_TYPE = "redis" # Flask-Caching related configs
39+
CACHE_KEY_PREFIX = 'whyis_cache_'
40+
CACHE_REDIS_URL = 'redis://redis:6379/0'
41+
CACHE_DEFAULT_TIMEOUT = 0
42+
MULTIUSER = True
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
{% for package in cookiecutter.__freeze %}{{ package }}
2-
{% endfor %}
3-
mod-wsgi==4.9.0

0 commit comments

Comments
 (0)