diff --git a/ansible/Dockerfile b/ansible/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ebab1f77bb6a8c2024011ec387d922079485dfd3 --- /dev/null +++ b/ansible/Dockerfile @@ -0,0 +1,13 @@ +FROM centos:7 + +RUN yum install -y epel-release wget gcc https://repo.ius.io/ius-release-el7.rpm +RUN yum update -y +RUN yum install -y python35u python35u-libs python35u-devel python35u-pip openssl-devel libffi-devel +RUN pip3.5 install ansible +RUN yum install -y python-pip +RUN python -m pip install --upgrade pip +COPY . ansible/ +WORKDIR ansible +RUN ansible-playbook -vvv -i ./hosts_local deploy.yaml --extra-vars "deploy_user_name=root docker=true" + +CMD ["jass", "serve"] diff --git a/ansible/deploy.yaml b/ansible/deploy.yaml index c97757c46384edefd2ab20917b0c62fd8b8a7113..a697f561a4f0fac68b29755f9b8bc1f2bf4c1fdc 100644 --- a/ansible/deploy.yaml +++ b/ansible/deploy.yaml @@ -65,20 +65,36 @@ name: wheel executable: pip3.6 # install jass - - pip: + - name: install jass from gitlab + pip: name: git+https://gitlab.pasteur.fr/statistical-genetics/jass.git state: forcereinstall executable: pip3.6 - # install frozen JASS requirements + when: not docker + - name: install jass from local + pip: + chdir: .. + name: . + state: forcereinstall + executable: pip3.6 + when: docker + - pip: + chdir: .. + requirements: requirements.txt + state: forcereinstall + executable: pip3.6 + when: docker - name: download JASS frozen requirements file get_url: url: https://gitlab.pasteur.fr/statistical-genetics/jass/raw/master/requirements.txt dest: /tmp/requirements.txt force: yes + when: not docker - pip: requirements: /tmp/requirements.txt state: forcereinstall executable: pip3.6 + when: not docker - pip: name: uwsgi executable: pip3.6 diff --git a/ansible/docker-compose.yaml b/ansible/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f88bf652ad7dcdda4db3871cb10c5e675ef9c30d --- /dev/null +++ b/ansible/docker-compose.yaml @@ -0,0 +1,50 @@ + +version: '3.1' +services: + rabbitmq: + image: rabbitmq:3-alpine + ports: + - 15672:15672 + - 5672:5672 + environment: + RABBITMQ_ERLANG_COOKIE: ${RABBITMQ_ERLANG_COOKIE} + RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER} + RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS} + RABBITMQ_NODE_PORT: ${RABBITMQ_NODE_PORT} + healthcheck: + test: ['CMD', 'rabbitmqctl', 'status'] + interval: 30s + timeout: 15s + retries: 3 + celery: + build: + context: . + command: ['celery', '-A', 'jass', 'worker'] + environment: + CELERY_BROKER_URL: ${CELERY_BROKER_URL} + CELERY_RESULT_BACKEND: ${CELERY_RESULT_BACKEND} + CACHE_REDIS_URL: ${CACHE_REDIS_URL} + SESSION_TYPE: ${SESSION_TYPE} + SESSION_REDIS_URL: ${SESSION_REDIS_URL} + LC_ALL: en_US.utf-8 + JASS_RABBITMQ_URL: 'amqp://guest:guest@rabbitmq:5672' + depends_on: + - rabbitmq + app: + build: + context: . + image: flask-celery-rabbitmq-example-app:latest + command: ['jass', 'serve'] + environment: + CELERY_BROKER_URL: ${CELERY_BROKER_URL} + CELERY_RESULT_BACKEND: ${CELERY_RESULT_BACKEND} + CACHE_REDIS_URL: ${CACHE_REDIS_URL} + SESSION_TYPE: ${SESSION_TYPE} + SESSION_REDIS_URL: ${SESSION_REDIS_URL} + volumes: + - ../data/initTable.hdf5:/usr/local/lib/python3.6/site-packages/data/initTable.hdf5 # for dev purpose only !!! + ports: + - '8080:8080' + depends_on: + - rabbitmq + - celery diff --git a/ansible/hosts_local b/ansible/hosts_local new file mode 100644 index 0000000000000000000000000000000000000000..7ca1165b172468f70058187868698900e49a53ca --- /dev/null +++ b/ansible/hosts_local @@ -0,0 +1 @@ +127.0.0.1 ansible_connection=local diff --git a/jass/__init__.py b/jass/__init__.py index 07c47d0f2b099b17e63986adb6d290309638758f..ce5630a2428a8154e20f8c463a1a76b537da4c93 100644 --- a/jass/__init__.py +++ b/jass/__init__.py @@ -15,12 +15,19 @@ Submodules wsgi server """ +import os + from celery import Celery + import jass.models.project def make_celery(app): celery = Celery(jass.models.project) + if 'CELERY_CONFIG_MODULE' in os.environ: + celery.config_from_envvar('CELERY_CONFIG_MODULE') + else: + celery.config_from_object('jass.celeryconfig') celery.conf.update(app.config) TaskBase = celery.Task diff --git a/jass/celeryconfig.py b/jass/celeryconfig.py new file mode 100644 index 0000000000000000000000000000000000000000..87314442cf73428c39798cd87a64be37c1560bc3 --- /dev/null +++ b/jass/celeryconfig.py @@ -0,0 +1,14 @@ +import os + +## Broker settings. +broker_url = os.getenv('JASS_RABBITMQ_URL','amqp://guest:guest@localhost:5672//') + +# List of modules to import when the Celery worker starts. +#imports = ('myapp.tasks',) + +## Using the database to store task state and results. +#result_backend = 'db+sqlite:///results.db' + +#task_annotations = {'tasks.add': {'rate_limit': '10/s'}} + +