1
0
mirror of https://github.com/daniviga/bite.git synced 2024-12-23 08:41:24 +01:00
This commit is contained in:
Daniele Viganò 2020-06-16 22:48:58 +02:00
parent ffc12992c4
commit 2a443815b0
Signed by: dani
GPG Key ID: DB49AFC03C40EE02
10 changed files with 61 additions and 60 deletions

View File

@ -6,7 +6,7 @@ from freedcs import settings
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
DEBUG = False
ALLOWED_HOSTS = ['*']
@ -21,9 +21,10 @@ DATABASES = {
}
}
MQTT_BROKER = {
'HOST': 'rabbitmq',
'PORT': 1883,
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
SKIP_WHITELIST = True

View File

@ -1,12 +1,13 @@
version: "3.7"
edge-host:
<<: *service_default
image: docker:dind
privileged: true
environment:
DOCKER_TLS_CERTDIR:
# networks:
# - net
ports:
- "127.0.0.1:22375:2375"
services:
edge-host:
<<: *service_default
image: docker:dind
privileged: true
environment:
DOCKER_TLS_CERTDIR:
# networks:
# - net
ports:
- "127.0.0.1:22375:2375"

View File

@ -8,13 +8,13 @@ services:
freedcs:
volumes:
- "./django/production.py.sample:/srv/freedcs/freedcs/production.py"
- "./django/production.py.sample:/srv/app/freedcs/freedcs/production.py"
command: ["gunicorn", "-b", "0.0.0.0:8000", "freedcs.wsgi:application"]
data-migration:
volumes:
- "./django/production.py.sample:/srv/freedcs/freedcs/production.py"
- "./django/production.py.sample:/srv/app/freedcs/freedcs/production.py"
mqtt-to-db:
volumes:
- "./django/production.py.sample:/srv/freedcs/freedcs/production.py"
- "./django/production.py.sample:/srv/app/freedcs/freedcs/production.py"

View File

@ -32,22 +32,16 @@ services:
networks:
- net
rabbitmq:
broker:
<<: *service_default
image: rabbitmq:3-management-alpine
# environment: # we use unauth access atm
# RABBITMQ_DEFAULT_VHOST: "freedcs"
# RABBITMQ_DEFAULT_USER: "freedcs"
# RABBITMQ_DEFAULT_PASS: "password"
volumes:
- ./rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
image: eclipse-mosquitto
networks:
- net
ports:
- "1883:1883"
- "15672:15672"
ingress:
<<: *service_default
image: traefik:v2.2
command: --api.insecure=true --providers.docker
ports:
@ -66,7 +60,7 @@ services:
dockerfile: ./docker/django/Dockerfile
image: daniviga/freedcs
volumes:
- "../freedcs:/srv/freedcs"
- "../freedcs:/srv/app/freedcs"
command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
networks:
- net
@ -80,7 +74,7 @@ services:
data-migration:
image: daniviga/freedcs
volumes:
- "../freedcs:/srv/freedcs"
- "../freedcs:/srv/app/freedcs"
command: ["python3", "manage.py", "migrate", "--noinput"]
networks:
- net
@ -89,11 +83,11 @@ services:
<<: *service_default
image: daniviga/freedcs
volumes:
- "../freedcs:/srv/freedcs"
- "../freedcs:/srv/app/freedcs"
command: ["python3", "manage.py", "mqtt-to-db"]
networks:
- net
depends_on:
- data-migration
- timescale
- rabbitmq
- broker

View File

@ -0,0 +1,18 @@
version: "3.7"
services:
broker:
image: rabbitmq:3-management-alpine
# environment: # we use unauth access atm
# RABBITMQ_DEFAULT_VHOST: "freedcs"
# RABBITMQ_DEFAULT_USER: "freedcs"
# RABBITMQ_DEFAULT_PASS: "password"
volumes:
- ./mqtt/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
networks:
- net
ports:
- "1883:1883"
- "15672:15672"
init: true
restart: always

View File

@ -0,0 +1,14 @@
version: "3.7"
services:
broker:
image: vernemq/vernemq
environment:
DOCKER_VERNEMQ_ALLOW_ANONYMOUS: "on"
DOCKER_VERNEMQ_ACCEPT_EULA: "yes"
networks:
- net
ports:
- "1883:1883"
init: true
restart: always

View File

@ -1,27 +0,0 @@
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

View File

@ -129,7 +129,7 @@ STATIC_URL = '/static/'
SKIP_WHITELIST = True
MQTT_BROKER = {
'HOST': 'rabbitmq',
'HOST': 'broker',
'PORT': '1883',
}

View File

@ -42,8 +42,8 @@ class TelemetryLatest(ModelViewSet):
def retrieve(self, request, device=None):
queryset = Telemetry.objects.filter(
device__serial=device).order_by('-time')[0]
device__serial=device).order_by('-time')
if not queryset:
raise Http404
serializer = TelemetrySerializer(queryset)
serializer = TelemetrySerializer(queryset[0])
return Response(serializer.data)