From ff7486f2cd1c0a86afb3cd9720f9cffcfb9f5312 Mon Sep 17 00:00:00 2001 From: Artur Nowakowski Date: Wed, 24 Jul 2019 19:03:02 +0200 Subject: [PATCH] Created dockerfile and docker-compose manifest --- Dockerfile | 26 ++++++++++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ tapiriik/settings.py | 6 +++--- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..582f53304 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:latest + +# install python +RUN apt-get update \ + && apt-get install -y python3-pip python3-dev \ + && cd /usr/local/bin \ + && ln -s /usr/bin/python3 python \ + && pip3 install --upgrade pip + +# copy project +COPY . / + +# install libs +RUN apt-get -y install git libxslt-dev libxml2-dev python3-lxml python3-crypto + +# install requirements +RUN pip3 install -r requirements.txt + +# rename settings example com +RUN cp tapiriik/local_settings.py.example tapiriik/local_settings.py + +# generate keys +RUN python3 credentialstore_keygen.py >> tapiriik/local_settings.py + +# run server, worker and scheduler +ENTRYPOINT python3 manage.py runserver 0.0.0.0:8000 && python3 sync_worker.py && python3 sync_scheduler.py \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..9932ccd51 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' +services: + tapiriik: + build: . + environment: + - RABBITMQ_BROKER_URL=amqp://guest@tapiriik_rabbitmq// + - MONGO_HOST=mongodb://root:example@tapiriik_mongo:27017/admin + - REDIS_HOST=tapiriik_redis + ports: + - "8000:8000" + links: + - tapiriik_redis + - tapiriik_mongo + - tapiriik_rabbitmq + tapiriik_redis: + image: redis + tapiriik_mongo: + image: mongo + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + tapiriik_rabbitmq: + image: rabbitmq:3-management \ No newline at end of file diff --git a/tapiriik/settings.py b/tapiriik/settings.py index 9ee91f0a7..5b2d75244 100644 --- a/tapiriik/settings.py +++ b/tapiriik/settings.py @@ -201,12 +201,12 @@ TEST_RUNNER = 'tapiriik.testing.MongoDBTestRunner' -MONGO_HOST = "localhost" +MONGO_HOST = os.getenv("MONGO_HOST", "localhost") MONGO_REPLICA_SET = None MONGO_CLIENT_OPTIONS = {} MONGO_FULL_WRITE_CONCERN = 1 -REDIS_HOST = "localhost" +REDIS_HOST = os.getenv("REDIS_HOST", "localhost") REDIS_CLIENT_OPTIONS = {} WEB_ROOT = 'http://localhost:8000' @@ -267,7 +267,7 @@ HTTP_SOURCE_ADDR = "0.0.0.0" -RABBITMQ_BROKER_URL = "amqp://guest@localhost//" +RABBITMQ_BROKER_URL = os.getenv("RABBITMQ_BROKER_URL", "amqp://guest@localhost//") RABBITMQ_USER_QUEUE_STATS_URL = "http://guest:guest@localhost:15672/api/queues/%2F/tapiriik-users?lengths_age=3600&lengths_incr=60&msg_rates_age=3600&msg_rates_incr=60"