Add health check endpoint and update Docker Compose configuration

- Add HealthCheckView to authapp
- Update authapp/urls.py to include health check
- Update docker-compose.yml for backend services
- Add frontend service to docker-compose.yml
- Add external config for frontend
This commit is contained in:
2025-02-28 21:39:51 +00:00
parent 90fbd42e40
commit 867994dc87
3 changed files with 63 additions and 35 deletions

View File

@@ -1,9 +1,10 @@
from django.urls import path
from .views import CustomAuthToken, RegenerateTokenView, VerifyTokenView, get_csrf_token
from .views import CustomAuthToken, RegenerateTokenView, VerifyTokenView, get_csrf_token, HealthCheckView
urlpatterns = [
path('login/', CustomAuthToken.as_view(), name='login'),
path('regenerate-token/', RegenerateTokenView.as_view(), name='regenerate-token'),
path('verify-token/', VerifyTokenView.as_view(), name='verify-token'),
path('get-csrf-token/', get_csrf_token, name='get-csrf-token'),
path('get-csrf-token/', get_csrf_token, name='get-csrf-token'),
path('health/', HealthCheckView.as_view(), name='health-check'),
]

View File

@@ -4,7 +4,7 @@ from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.authtoken.models import Token
from rest_framework.response import Response
from .serializers import UserSerializer
from rest_framework.permissions import IsAuthenticated
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework import status
from django.http import JsonResponse
@@ -42,3 +42,7 @@ class VerifyTokenView(APIView):
}, status=status.HTTP_200_OK)
class HealthCheckView(APIView):
permission_classes = [AllowAny]
def get(self, request, *args, **kwargs):
return Response({"status": "healthy"})

View File

@@ -1,46 +1,69 @@
version: '3.8'
services:
frontend:
image: registry.resk-u.ch/clerc/clerc-frontend:latest
networks:
- main-swarm-network
ports:
- "3000:3000"
volumes:
- /home/prod/reskreen-frontend/.env:/app/frontend-app/.env
labels:
- shepherd.enable=true
- node.labels.reskreen-ready=true
backend:
image: registry.resk-u.ch/clerc/reskreen:latest
networks:
- main-swarm-network
ports:
- "8081:8080"
volumes:
- reskreen-data:/app/config
labels:
- shepherd.enable=true
- node.labels.reskreen-ready=true
node.labels.reskreen-ready: 'true'
volumes:
- reskreen-data:/app/config
networks:
- main-swarm-network
logging:
driver: json-file
deploy:
restart_policy:
condition: on-failure
placement:
constraints:
- node.labels.reskreen-ready==true
backend-cron:
image: registry.resk-u.ch/clerc/reskreen:latest
command: /app/start_crond.sh
volumes:
- reskreen-data:/app/config
command:
- /app/start_crond.sh
labels:
- shepherd.enable=true
- node.labels.reskreen-ready=true
node.labels.reskreen-ready: 'true'
volumes:
- reskreen-data:/app/config
networks:
- default
logging:
driver: json-file
frontend:
image: registry.resk-u.ch/clerc/clerc-frontend:latest
labels:
node.labels.reskreen-ready: 'true'
networks:
- main-swarm-network
configs:
-
source: env-reskreen-frontend
target: /app/frontend-app/.env
logging:
driver: json-file
deploy:
update_config:
delay: 10s
restart_policy:
condition: on-failure
max_attempts: 3
placement:
constraints:
- node.labels.reskreen-ready==true
networks:
default:
driver: overlay
main-swarm-network:
external: true
volumes:
reskreen-data:
driver: local
driver_opts:
type: none
device: /home/prod/Reskreen
o: bind
networks:
main-swarm-network:
type: none
configs:
env-reskreen-frontend:
external: true