diff --git a/Dockerfile b/Dockerfile index 74f8560..b2cf0de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN : \ gnupg \ wget \ gettext \ + curl \ && rm -rf /var/lib/apt/lists* \ && : diff --git a/docker-compose.yml b/docker-compose.yml index 58fd6d2..dfd81a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,16 +34,27 @@ services: backend: <<: *x-django + healthcheck: + test: ["CMD", "curl", "--fail", "http://localhost:8000/healthz/"] + interval: 5s + timeout: 2s + retries: 10 + start_interval: 10s ports: - "8000:8000" dramatiq: <<: *x-django command: ["/app/scripts/run-dramatiq.sh"] + depends_on: + backend: + condition: service_healthy scheduler: <<: *x-django command: [ "/app/scripts/run-scheduler.sh" ] + depends_on: + - dramatiq gotenberg: image: gotenberg/gotenberg:8 diff --git a/facturio/urls.py b/facturio/urls.py index f5bd9fb..bea6bf8 100644 --- a/facturio/urls.py +++ b/facturio/urls.py @@ -2,6 +2,7 @@ from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.http import HttpRequest from django.http import HttpResponse +from django.http import JsonResponse from django.shortcuts import render from django.urls import include from django.urls import path @@ -11,7 +12,7 @@ def landing_page(req: HttpRequest) -> HttpResponse: return render(req, 'facturio/index.html') -urlpatterns = i18n_patterns( +app_patterns = i18n_patterns( path('', landing_page, name='main-page'), path('accounts/', include('accounts.urls')), path('subjects/', include('subjects.urls')), @@ -19,3 +20,6 @@ urlpatterns = i18n_patterns( path('admin/', admin.site.urls), prefix_default_language=False, ) +urlpatterns = [ + path('healthz/', lambda _: JsonResponse(dict(status='Alive'))), +] + app_patterns diff --git a/scripts/run.sh b/scripts/run.sh index beeb6ef..206ed2a 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -11,8 +11,8 @@ echo "Compiling messages..." echo "Migrating..." ./manage.py migrate --no-input -#echo "Checking for errors..." -#./manage.py check --deploy --fail-level WARNING +echo "Checking for errors..." +./manage.py check --deploy --fail-level WARNING uvicorn \ --host 0.0.0.0 \