From 11630c9a743ba1fed18cc9805dd78c35af7131b6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 10 Apr 2019 22:38:25 +0200 Subject: [PATCH] switch kubernetes deployment to daphne server --- Dockerfile | 4 ++-- .../passbook/templates/passbook-web-deployment.yaml | 2 +- passbook/app_gw/requirements.txt | 2 ++ passbook/core/asgi.py | 13 +++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 passbook/core/asgi.py diff --git a/Dockerfile b/Dockerfile index 45bf8be75..0647936bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./requirements.txt /app/ WORKDIR /app/ -RUN apt-get update && apt-get install build-essential libssl-dev libffi-dev -y && \ +RUN apt-get update && apt-get install build-essential libssl-dev libffi-dev libpq-dev -y && \ mkdir /app/static/ && \ pip install -r requirements.txt && \ pip install psycopg2 && \ @@ -23,7 +23,7 @@ COPY --from=build /app/static /app/static/ WORKDIR /app/ -RUN apt-get update && apt-get install build-essential libssl-dev libffi-dev -y && \ +RUN apt-get update && apt-get install build-essential libssl-dev libffi-dev libpq-dev -y && \ pip install -r requirements.txt && \ pip install psycopg2 && \ adduser --system --home /app/ passbook && \ diff --git a/helm/passbook/templates/passbook-web-deployment.yaml b/helm/passbook/templates/passbook-web-deployment.yaml index 2308300ca..df98947a2 100644 --- a/helm/passbook/templates/passbook-web-deployment.yaml +++ b/helm/passbook/templates/passbook-web-deployment.yaml @@ -29,7 +29,7 @@ spec: image: "docker.pkg.beryju.org/passbook:{{ .Values.image.tag }}" imagePullPolicy: IfNotPresent command: ["/bin/sh","-c"] - args: ["./manage.py migrate && ./manage.py web"] + args: ["./manage.py migrate && daphne -p 8000 passbook.core.asgi:application"] ports: - name: http containerPort: 8000 diff --git a/passbook/app_gw/requirements.txt b/passbook/app_gw/requirements.txt index 934e9cc25..19b5cf2d4 100644 --- a/passbook/app_gw/requirements.txt +++ b/passbook/app_gw/requirements.txt @@ -3,3 +3,5 @@ urllib3[secure] channels service_identity websocket-client +daphne<2.3.0 +asgiref~=2.3 diff --git a/passbook/core/asgi.py b/passbook/core/asgi.py new file mode 100644 index 000000000..249debe64 --- /dev/null +++ b/passbook/core/asgi.py @@ -0,0 +1,13 @@ +""" +ASGI entrypoint. Configures Django and then runs the application +defined in the ASGI_APPLICATION setting. +""" + +import os + +import django +from channels.routing import get_default_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passbook.core.settings") +django.setup() +application = get_default_application()