diff --git a/Dockerfile b/Dockerfile-web similarity index 66% rename from Dockerfile rename to Dockerfile-web index c4b594fcdcda46831bfebf7b7a743ba94e2096b6..c90a8d223d544227d7ddd54ca3be51b7694c6754 100644 --- a/Dockerfile +++ b/Dockerfile-web @@ -10,14 +10,8 @@ RUN apt-get update \ python3.5-dev \ python3-pip \ python3-setuptools \ - rabbitmq-server \ - redis-server \ r-bioc-limma RUN pip3 install wheel RUN pip3 install -e /app --default-timeout 180 -RUN /etc/init.d/redis-server start -RUN /etc/init.d/rabbitmq-server start -RUN celery worker -A fractalis:celery -D -l info -EXPOSE 5000 CMD ["python3", "fractalis/__init__.py"] diff --git a/Dockerfile-worker b/Dockerfile-worker new file mode 100644 index 0000000000000000000000000000000000000000..2677415489fea0b060b007af4fed602f10e91c23 --- /dev/null +++ b/Dockerfile-worker @@ -0,0 +1,17 @@ +FROM buildpack-deps:stretch + +WORKDIR /app +COPY . /app + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + r-base \ + python3.5 \ + python3.5-dev \ + python3-pip \ + python3-setuptools \ + r-bioc-limma +RUN pip3 install wheel +RUN pip3 install -e /app --default-timeout 180 + +CMD ["celery", "worker", "-A", "fractalis:celery"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..1a8389d3116bd4e89f4d67f0b62624b8e091d0bb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' +services: + web: + build: + context: . + dockerfile: Dockerfile-web + environment: + - FRACTALIS_CONFIG=${FRACTALIS_CONFIG} + - REDIS_HOST=redis + - RABBITMQ_HOST=rabbitmq + ports: + - '5000:5000' + worker: + build: + context: . + dockerfile: Dockerfile-worker + environment: + - FRACTALIS_CONFIG=${FRACTALIS_CONFIG} + - REDIS_HOST=redis + - RABBITMQ_HOST=rabbitmq + redis: + image: 'redis:alpine' + rabbitmq: + image: 'rabbitmq:alpine' diff --git a/fractalis/config.py b/fractalis/config.py index 88d3cd4184f65fdb9f98783a3a69c30f0b2e7a89..0534dad16b97613ea63d03ac324e0c0eaaa4087e 100644 --- a/fractalis/config.py +++ b/fractalis/config.py @@ -8,7 +8,7 @@ from datetime import timedelta SECRET_KEY = 'OVERWRITE ME IN PRODUCTION!!!' DEBUG = False TESTING = False -REDIS_HOST = '127.0.0.1' +REDIS_HOST = os.environ.get('REDIS_HOST') or '127.0.0.1' REDIS_PORT = '6379' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = False @@ -16,7 +16,8 @@ SESSION_REFRESH_EACH_REQUEST = True PERMANENT_SESSION_LIFETIME = timedelta(days=1) # Celery -BROKER_URL = 'amqp://' +RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST') or '127.0.0.1' +BROKER_URL = 'amqp://guest:guest@{}:5672//'.format(RABBITMQ_HOST) CELERY_RESULT_BACKEND = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT) CELERYD_TASK_SOFT_TIME_LIMIT = 60 * 20 CELERYD_TASK_TIME_LIMIT = 60 * 30 diff --git a/setup.py b/setup.py index e18ec25234488af8a1e3f023455ec0c5005a2c42..c87b2b6f5588f303fcb4f01a179a0b4962387c03 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,8 @@ setup( 'requests==2.18.4', 'PyYAML==3.12', 'pycryptodomex==3.4.7', - 'rpy2==2.9.0' + 'rpy2==2.9.0', + 'flake8==3.5.0' ], setup_requires=[ 'pytest-runner==2.12.1',