Implement #11 mhu/11-add-docker-compose-setup: Add compose setup #12

Merged
mhu merged 9 commits from mhu/11-add-docker-compose-setup into develop 2024-11-17 20:19:29 +01:00
4 changed files with 19 additions and 2 deletions
Showing only changes of commit 561b2aed27 - Show all commits

View File

@ -1,5 +1,5 @@
FROM alpine:latest FROM alpine:latest
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn curl
COPY . /home/shimatta/kenkyusho COPY . /home/shimatta/kenkyusho
WORKDIR /home/shimatta/kenkyusho WORKDIR /home/shimatta/kenkyusho
RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt

View File

@ -22,6 +22,12 @@ services:
depends_on: depends_on:
shimatta-kenkyusho-db: shimatta-kenkyusho-db:
condition: service_healthy condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f localhost:8000/healthcheck"]
interval: 5s
timeout: 5s
retries: 5
start_period: 30s
shimatta-kenkyusho-db: shimatta-kenkyusho-db:
image: postgres:16.5-alpine image: postgres:16.5-alpine

View File

@ -16,4 +16,5 @@ urlpatterns = [
path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'), path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'),
path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'), path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'),
path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'), path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'),
path("healthcheck/", parts_views.health_check_view, name='parts-health-check'),
] ]

View File

@ -18,8 +18,10 @@ from .forms import *
from django.db.models import Q from django.db.models import Q
from django.db.models.functions import Lower from django.db.models.functions import Lower
from django.forms import formset_factory from django.forms import formset_factory
from django.http import HttpResponse
import uuid import uuid
ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1) ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1)
class QrSearchForm(forms.Form): class QrSearchForm(forms.Form):
@ -954,3 +956,11 @@ class ManufacturerDetailViewSet(LoginRequiredMixin, BaseTemplateMixin, DetailVie
return self.edit_manufacturer(request) return self.edit_manufacturer(request)
return super().post(request, *args, **kwargs) return super().post(request, *args, **kwargs)
def health_check_view(request) -> HttpResponse:
"""
Health checking view. Returns empty http response with HTTP status OK.
This will be used to check
"""
return HttpResponse(status=200)