From 2d01023a4b7cfdc4f296d75f7c02ee2fa1990fe1 Mon Sep 17 00:00:00 2001 From: Jan Koppe Date: Sun, 25 Feb 2024 11:24:42 +0100 Subject: [PATCH] maintenance: update to Django 5, Redis 7, Postgres 16, add dev SRS --- Dockerfile | 2 +- concierge/admin.py | 4 ++-- docker-compose.dev.yaml | 11 +++++++++-- portier/settings.py | 7 +++++-- requirements.txt | 2 +- restream/admin.py | 2 +- rtmp/admin.py | 4 ++-- rtmp/signals.py | 4 ++-- srs.dev.conf | 30 ++++++++++++++++++++++++++++++ 9 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 srs.dev.conf diff --git a/Dockerfile b/Dockerfile index 13d7d61..fc5806d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-alpine +FROM python:3.12-alpine WORKDIR /app # set env diff --git a/concierge/admin.py b/concierge/admin.py index 6eb526d..8071789 100644 --- a/concierge/admin.py +++ b/concierge/admin.py @@ -2,13 +2,13 @@ from django.contrib import admin from .models import Identity, Task +@admin.register(Identity) class IdentityAdmin(admin.ModelAdmin): fields = ['identity', 'name', 'notes', 'heartbeat'] +@admin.register(Task) class TaskAdmin(admin.ModelAdmin): fields = ['stream', 'type', 'config_id', 'configuration', 'claimed_by'] -admin.site.register(Identity, IdentityAdmin) -admin.site.register(Task, TaskAdmin) diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 6730e69..1dcb37b 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -24,10 +24,17 @@ services: - "EMAIL_HOST_USER=${EMAIL_HOST_USER}" - "EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}" redis: - image: redis:5-alpine + image: redis:7-alpine postgres: - image: postgres:11.7-alpine + image: postgres:16-alpine environment: POSTGRES_PASSWORD: "portier" POSTGRES_USER: "portier" POSTGRES_DB: "portier" + srs: + image: ossrs/srs:4 + ports: + - 1935:1935 + - 8888:8888 + volumes: + - ./srs.dev.conf:/usr/local/srs/conf/docker.conf:ro \ No newline at end of file diff --git a/portier/settings.py b/portier/settings.py index c4052f7..92b1b7c 100644 --- a/portier/settings.py +++ b/portier/settings.py @@ -26,6 +26,7 @@ SECRET_KEY = os.environ.get("SECRET_KEY", default="CHANGE_ME!") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = int(os.environ.get("DEBUG", default=0)) ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", default="*").split(" ") +CSRF_TRUSTED_ORIGINS = os.environ.get("DJANGO_CSRF_TRUSTED_ORIGINS", default="http://localhost").split(" ") DEFAULT_GROUP = 'default' @@ -68,6 +69,8 @@ AUTHENTICATION_BACKENDS = ( 'guardian.backends.ObjectPermissionBackend', ) +ANONYMOUS_USER_NAME = None + ROOT_URLCONF = 'portier.urls' TEMPLATES = [ @@ -103,7 +106,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators @@ -133,7 +135,6 @@ ACCOUNT_ACTIVATION_DAYS = 7 LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True -USE_L10N = True USE_TZ = True LANGUAGES = [ @@ -182,3 +183,5 @@ CELERY_RESULT_BACKEND = "redis://{}:{}".format(os.environ.get('REDIS_HOST', defa CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_RESULT_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json' + +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' diff --git a/requirements.txt b/requirements.txt index 3b7986f..9146fce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django==3.1.13 +django==5.0.2 django-registration>=3.1 django-bootstrap4 django-guardian diff --git a/restream/admin.py b/restream/admin.py index 3070e29..03795b4 100644 --- a/restream/admin.py +++ b/restream/admin.py @@ -3,8 +3,8 @@ from guardian.admin import GuardedModelAdmin from .models import RestreamConfig +@admin.register(RestreamConfig) class RestreamConfigAdmin(GuardedModelAdmin): fields = ['name', 'active', 'stream', 'format', 'target'] -admin.site.register(RestreamConfig, RestreamConfigAdmin) diff --git a/rtmp/admin.py b/rtmp/admin.py index cbbe9da..be29ecf 100644 --- a/rtmp/admin.py +++ b/rtmp/admin.py @@ -3,13 +3,13 @@ from guardian.admin import GuardedModelAdmin from .models import Application, Stream +@admin.register(Application) class ApplicationAdmin(GuardedModelAdmin): fields = ['name'] +@admin.register(Stream) class StreamAdmin(GuardedModelAdmin): fields = ['application', 'stream', 'name', 'publish_counter'] -admin.site.register(Application, ApplicationAdmin) -admin.site.register(Stream, StreamAdmin) diff --git a/rtmp/signals.py b/rtmp/signals.py index ab78089..df2eb03 100644 --- a/rtmp/signals.py +++ b/rtmp/signals.py @@ -1,4 +1,4 @@ from django.dispatch import Signal -stream_active = Signal(providing_args=['stream', 'params']) -stream_inactive = Signal(providing_args=['stream', 'params']) +stream_active = Signal() +stream_inactive = Signal() diff --git a/srs.dev.conf b/srs.dev.conf new file mode 100644 index 0000000..70d3aee --- /dev/null +++ b/srs.dev.conf @@ -0,0 +1,30 @@ +listen 1935; +max_connections 1000; +srs_log_tank console; +pid ./objs/srs.pid; +utc_time on; +inotify_auto_reload on; +daemon off; + +http_api { + enabled on; + listen 8888; +} + +srt_server { + enabled on; + listen 8889; +} + +vhost __defaultVhost__ { + security { + enabled on; + allow publish all; + allow play all; + } + http_hooks { + enabled on; + on_publish http://app/rtmp/callback/srs; + on_unpublish http://app/rtmp/callback/srs; + } +} \ No newline at end of file