diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ad8d5d6..bf0e585 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -19,7 +19,7 @@ services: networks: - net ports: - - "127.0.0.1:123:123/udp" + - "123:123/udp" timescale: <<: *service_default @@ -34,20 +34,6 @@ services: ports: - "127.0.0.1:5432:5432" - # mosquitto simple deployment - # mqtt: - # <<: *service_default - # # image: vernemq/vernemq - # # environment: - # # DOCKER_VERNEMQ_ALLOW_ANONYMOUS: "on" - # # DOCKER_VERNEMQ_ACCEPT_EULA: "yes" - # image: eclipse-mosquitto - # networks: - # - net - # ports: - # - "1883:1883" - # # - "9001:9001" # mqtt via websocket - rabbitmq: <<: *service_default image: rabbitmq:3-management-alpine @@ -61,16 +47,56 @@ services: - net ports: - "1883:1883" - - "5672:5672" - "15672:15672" - edge: + # edge: + # <<: *service_default + # image: docker:dind + # privileged: true + # environment: + # DOCKER_TLS_CERTDIR: + # networks: + # - net + # ports: + # - "127.0.0.1:22375:2375" + + freedcs: <<: *service_default - image: docker:dind - privileged: true - environment: - DOCKER_TLS_CERTDIR: + build: + context: .. + dockerfile: ./docker/django/Dockerfile + image: daniviga/freedcs + volumes: + - "../freedcs:/srv/freedcs" + - "./django/production.py.sample:/srv/freedcs/freedcs/production.py" + command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"] networks: - net ports: - - "127.0.0.1:22375:2375" + - "8000:8000" + depends_on: + - data-migration + - timescale + + data-migration: + image: daniviga/freedcs + volumes: + - "../freedcs:/srv/freedcs" + - "./django/production.py.sample:/srv/freedcs/freedcs/production.py" + command: ["python3", "manage.py", "migrate", "--noinput"] + networks: + - net + + mqtt-to-db: + <<: *service_default + image: daniviga/freedcs + volumes: + - "../freedcs:/srv/freedcs" + - "./django/production.py.sample:/srv/freedcs/freedcs/production.py" + command: ["python3", "manage.py", "mqtt-to-db"] + networks: + - net + depends_on: + - data-migration + - timescale + - rabbitmq diff --git a/freedcs/freedcs/production.py.sample b/freedcs/freedcs/production.py.sample new file mode 100644 index 0000000..3e1fedf --- /dev/null +++ b/freedcs/freedcs/production.py.sample @@ -0,0 +1,27 @@ +from freedcs import settings + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'i4z%50+4b4ek(l0#!w2-r1hpo%&r6tk7p$p_-(=6d!c9n=g5m&' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'freedcs', + 'USER': 'freedcs', + 'PASSWORD': 'password', + 'HOST': 'timescale', + 'PORT': '5432', + } +} + +MQTT_BROKER = { + 'HOST': 'rabbitmq', + 'PORT': '1883', +} + +SKIP_WHITELIST = True diff --git a/freedcs/freedcs/settings.py b/freedcs/freedcs/settings.py index 17d4151..0f94a53 100644 --- a/freedcs/freedcs/settings.py +++ b/freedcs/freedcs/settings.py @@ -82,7 +82,7 @@ DATABASES = { 'NAME': 'freedcs', 'USER': 'freedcs', 'PASSWORD': 'password', - 'HOST': '127.0.0.1', + 'HOST': 'timescale', 'PORT': '5432', } } @@ -127,3 +127,17 @@ USE_TZ = True STATIC_URL = '/static/' SKIP_WHITELIST = True + +MQTT_BROKER = { + 'HOST': 'rabbitmq', + 'PORT': '1883', +} + +# If no local_settings.py is availble in the current folder let's try to +# load it from the application root +try: + from freedcs.production import * +except ImportError: + # If a local_setting.py does not exist + # settings in this file only will be used + pass diff --git a/requirements.txt b/requirements.txt index e3e43ba..84a744d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Django djangorestframework psycopg2-binary -kombu +paho-mqtt==1.5.0 +asyncio-mqtt==0.5.0