1
0
mirror of https://github.com/daniviga/bite.git synced 2024-11-23 05:16:13 +01:00

Project renaming (#14)

* Renaming

* Make Django migrations sync to DB availability
This commit is contained in:
Daniele Viganò 2020-06-17 20:08:10 +02:00 committed by GitHub
parent 32b6350c35
commit 09cf23554a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 48 additions and 44 deletions

View File

@ -1,2 +1,2 @@
# freedcs # beer
Playing with IoT Playing with IoT

View File

@ -1,4 +1,4 @@
"""freedcs URL Configuration """beer URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/ https://docs.djangoproject.com/en/3.0/topics/http/urls/

View File

@ -1,5 +1,5 @@
""" """
ASGI config for freedcs project. ASGI config for beer project.
It exposes the ASGI callable as a module-level variable named ``application``. It exposes the ASGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'freedcs.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'beer.settings')
application = get_asgi_application() application = get_asgi_application()

View File

@ -1,5 +1,5 @@
""" """
Django settings for freedcs project. Django settings for beer project.
Generated by 'django-admin startproject' using Django 3.0.6. Generated by 'django-admin startproject' using Django 3.0.6.
@ -52,7 +52,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
ROOT_URLCONF = 'freedcs.urls' ROOT_URLCONF = 'beer.urls'
TEMPLATES = [ TEMPLATES = [
{ {
@ -70,7 +70,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = 'freedcs.wsgi.application' WSGI_APPLICATION = 'beer.wsgi.application'
# Database # Database
@ -79,8 +79,8 @@ WSGI_APPLICATION = 'freedcs.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'freedcs', 'NAME': 'beer',
'USER': 'freedcs', 'USER': 'beer',
'PASSWORD': 'password', 'PASSWORD': 'password',
'HOST': 'timescale', 'HOST': 'timescale',
'PORT': '5432', 'PORT': '5432',
@ -136,7 +136,7 @@ MQTT_BROKER = {
# If no local_settings.py is availble in the current folder let's try to # If no local_settings.py is availble in the current folder let's try to
# load it from the application root # load it from the application root
try: try:
from freedcs.production import * from beer.production import *
except ImportError: except ImportError:
# If a local_setting.py does not exist # If a local_setting.py does not exist
# settings in this file only will be used # settings in this file only will be used

View File

@ -1,4 +1,4 @@
"""freedcs URL Configuration """beer URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/ https://docs.djangoproject.com/en/3.0/topics/http/urls/

View File

@ -1,5 +1,5 @@
""" """
WSGI config for freedcs project. WSGI config for beer project.
It exposes the WSGI callable as a module-level variable named ``application``. It exposes the WSGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'freedcs.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'beer.settings')
application = get_wsgi_application() application = get_wsgi_application()

View File

@ -5,7 +5,7 @@ import sys
def main(): def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'freedcs.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'beer.settings')
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:

View File

@ -1,4 +1,4 @@
"""freedcs URL Configuration """beer URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/ https://docs.djangoproject.com/en/3.0/topics/http/urls/

View File

@ -6,16 +6,18 @@ RUN apk update && apk add gcc musl-dev postgresql-dev \
FROM python:3.8-alpine FROM python:3.8-alpine
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE "freedcs.settings" ENV DJANGO_SETTINGS_MODULE "beer.settings"
RUN apk update && apk add --no-cache postgresql-libs RUN apk update && apk add --no-cache postgresql-libs \
&& wget https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz -qO- \
| tar -xz -C /usr/local/bin
COPY --from=builder /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/ COPY --from=builder /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
COPY --chown=1000:1000 freedcs /srv/app/freedcs COPY --chown=1000:1000 beer /srv/app/beer
COPY --chown=1000:1000 requirements.txt /tmp/requirements.txt COPY --chown=1000:1000 requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt && rm /tmp/requirements.txt RUN pip3 install -r /tmp/requirements.txt && rm /tmp/requirements.txt
USER 1000:1000 USER 1000:1000
WORKDIR /srv/app/freedcs WORKDIR /srv/app/beer
EXPOSE 8000/tcp EXPOSE 8000/tcp
CMD ["python3", "manage.py", "runserver"] CMD ["python3", "manage.py", "runserver"]

View File

@ -1,6 +1,6 @@
# vim: syntax=python # vim: syntax=python
from freedcs import settings from beer import settings
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'i4z%50+4b4ek(l0#!w2-r1hpo%&r6tk7p$p_-(=6d!c9n=g5m&' SECRET_KEY = 'i4z%50+4b4ek(l0#!w2-r1hpo%&r6tk7p$p_-(=6d!c9n=g5m&'
@ -13,8 +13,8 @@ ALLOWED_HOSTS = ['*']
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'freedcs', 'NAME': 'beer',
'USER': 'freedcs', 'USER': 'beer',
'PASSWORD': 'password', 'PASSWORD': 'password',
'HOST': 'timescale', 'HOST': 'timescale',
'PORT': '5432', 'PORT': '5432',

View File

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

View File

@ -25,7 +25,7 @@ services:
<<: *service_default <<: *service_default
image: timescale/timescaledb:latest-pg12 image: timescale/timescaledb:latest-pg12
environment: environment:
POSTGRES_USER: "freedcs" POSTGRES_USER: "beer"
POSTGRES_PASSWORD: "password" POSTGRES_PASSWORD: "password"
volumes: volumes:
- "pgdata:/var/lib/postgresql/data" - "pgdata:/var/lib/postgresql/data"
@ -53,14 +53,14 @@ services:
# So that Traefik can listen to the Docker events # So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
freedcs: beer:
<<: *service_default <<: *service_default
build: build:
context: .. context: ..
dockerfile: ./docker/django/Dockerfile dockerfile: ./docker/django/Dockerfile
image: daniviga/freedcs image: daniviga/beer
volumes: volumes:
- "../freedcs:/srv/app/freedcs" - "../beer:/srv/app/beer"
command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"] command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
networks: networks:
- net - net
@ -69,21 +69,23 @@ services:
- data-migration - data-migration
- timescale - timescale
labels: labels:
- "traefik.http.routers.freedcs.rule=PathPrefix(`/`)" - "traefik.http.routers.beer.rule=PathPrefix(`/`)"
data-migration: data-migration:
image: daniviga/freedcs image: daniviga/beer
volumes: volumes:
- "../freedcs:/srv/app/freedcs" - "../beer:/srv/app/beer"
command: ["python3", "manage.py", "migrate", "--noinput"] command: ["dockerize", "-wait", "tcp://timescale:5432", "python3", "manage.py", "migrate", "--noinput"]
networks: networks:
- net - net
depends_on:
- timescale
mqtt-to-db: mqtt-to-db:
<<: *service_default <<: *service_default
image: daniviga/freedcs image: daniviga/beer
volumes: volumes:
- "../freedcs:/srv/app/freedcs" - "../beer:/srv/app/beer"
command: ["python3", "manage.py", "mqtt-to-db"] command: ["python3", "manage.py", "mqtt-to-db"]
networks: networks:
- net - net

View File

@ -13,7 +13,7 @@ services:
<<: *service_default <<: *service_default
build: build:
context: ../simulator context: ../simulator
image: daniviga/freedcs-device-simulator image: daniviga/beer-device-simulator
environment: environment:
IOT_HTTP: "http://192.168.10.123:8000" IOT_HTTP: "http://192.168.10.123:8000"
# IOT_SERIAL: "abcd1234" # IOT_SERIAL: "abcd1234"
@ -26,13 +26,13 @@ services:
<<: *service_default <<: *service_default
build: build:
context: ../simulator context: ../simulator
image: daniviga/freedcs-device-simulator image: daniviga/beer-device-simulator
environment: environment:
IOT_HTTP: "http://192.168.10.123:8000" IOT_HTTP: "http://192.168.10.123:8000"
IOT_MQTT: "192.168.10.123:1883" IOT_MQTT: "192.168.10.123:1883"
# IOT_SERIAL: "abcd1234" # IOT_SERIAL: "abcd1234"
# IOT_DELAY: 10 # IOT_DELAY: 10
IOT_DEBUG: 1 IOT_DEBUG: 1
command: ["/opt/freedcs/device_simulator.py", "-t", "mqtt"] command: ["/opt/beer/device_simulator.py", "-t", "mqtt"]
networks: networks:
- localnet - localnet

View File

@ -4,8 +4,8 @@ services:
broker: broker:
image: rabbitmq:3-management-alpine image: rabbitmq:3-management-alpine
# environment: # we use unauth access atm # environment: # we use unauth access atm
# RABBITMQ_DEFAULT_VHOST: "freedcs" # RABBITMQ_DEFAULT_VHOST: "beer"
# RABBITMQ_DEFAULT_USER: "freedcs" # RABBITMQ_DEFAULT_USER: "beer"
# RABBITMQ_DEFAULT_PASS: "password" # RABBITMQ_DEFAULT_PASS: "password"
volumes: volumes:
- ./mqtt/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins - ./mqtt/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins

View File

@ -1,7 +1,7 @@
FROM python:3.8-alpine FROM python:3.8-alpine
RUN pip3 install urllib3 paho-mqtt RUN pip3 install urllib3 paho-mqtt
COPY ./device_simulator.py /opt/freedcs/device_simulator.py COPY ./device_simulator.py /opt/beer/device_simulator.py
ENTRYPOINT ["python3"] ENTRYPOINT ["python3"]
CMD ["/opt/freedcs/device_simulator.py"] CMD ["/opt/beer/device_simulator.py"]