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

View File

@ -1,4 +1,4 @@
"""freedcs URL Configuration
"""beer URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
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``.
@ -11,6 +11,6 @@ import os
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()

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.
@ -52,7 +52,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'freedcs.urls'
ROOT_URLCONF = 'beer.urls'
TEMPLATES = [
{
@ -70,7 +70,7 @@ TEMPLATES = [
},
]
WSGI_APPLICATION = 'freedcs.wsgi.application'
WSGI_APPLICATION = 'beer.wsgi.application'
# Database
@ -79,8 +79,8 @@ WSGI_APPLICATION = 'freedcs.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'freedcs',
'USER': 'freedcs',
'NAME': 'beer',
'USER': 'beer',
'PASSWORD': 'password',
'HOST': 'timescale',
'PORT': '5432',
@ -136,7 +136,7 @@ MQTT_BROKER = {
# 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 *
from beer.production import *
except ImportError:
# If a local_setting.py does not exist
# 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:
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``.
@ -11,6 +11,6 @@ import os
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()

View File

@ -5,7 +5,7 @@ import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'freedcs.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'beer.settings')
try:
from django.core.management import execute_from_command_line
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:
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
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 --chown=1000:1000 freedcs /srv/app/freedcs
COPY --chown=1000:1000 beer /srv/app/beer
COPY --chown=1000:1000 requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt && rm /tmp/requirements.txt
USER 1000:1000
WORKDIR /srv/app/freedcs
WORKDIR /srv/app/beer
EXPOSE 8000/tcp
CMD ["python3", "manage.py", "runserver"]

View File

@ -1,6 +1,6 @@
# vim: syntax=python
from freedcs import settings
from beer 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&'
@ -13,8 +13,8 @@ ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'freedcs',
'USER': 'freedcs',
'NAME': 'beer',
'USER': 'beer',
'PASSWORD': 'password',
'HOST': 'timescale',
'PORT': '5432',

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
FROM python:3.8-alpine
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"]
CMD ["/opt/freedcs/device_simulator.py"]
CMD ["/opt/beer/device_simulator.py"]