feat: add build info handling and probe endpoint for services
This commit is contained in:
@@ -2,6 +2,10 @@ FROM python:3.10-slim
|
|||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV PYTHONPATH=/app
|
||||||
|
|
||||||
|
ARG BUILD_ID=dev
|
||||||
|
ARG BUILD_TIME_UTC=unknown
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends build-essential git \
|
&& apt-get install -y --no-install-recommends build-essential git \
|
||||||
@@ -22,6 +26,8 @@ COPY federation_authority /app/federation_authority
|
|||||||
COPY provider /app/provider
|
COPY provider /app/provider
|
||||||
COPY relying_party /app/relying_party
|
COPY relying_party /app/relying_party
|
||||||
|
|
||||||
|
RUN printf '{\"build_id\":\"%s\",\"built_at_utc\":\"%s\",\"image_marker\":\"cie-auth-image\"}\n' \"$BUILD_ID\" \"$BUILD_TIME_UTC\" > /app/__buildinfo__.json
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
COPY scripts /app/scripts
|
COPY scripts /app/scripts
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
BUILD_ID: ${CIE_AUTH_BUILD_ID:-dev}
|
||||||
|
BUILD_TIME_UTC: ${CIE_AUTH_BUILD_TIME_UTC:-unknown}
|
||||||
working_dir: /app/federation_authority
|
working_dir: /app/federation_authority
|
||||||
command: ["/app/federation_authority", "8000"]
|
command: ["/app/federation_authority", "8000"]
|
||||||
environment:
|
environment:
|
||||||
@@ -21,6 +24,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
BUILD_ID: ${CIE_AUTH_BUILD_ID:-dev}
|
||||||
|
BUILD_TIME_UTC: ${CIE_AUTH_BUILD_TIME_UTC:-unknown}
|
||||||
working_dir: /app/provider
|
working_dir: /app/provider
|
||||||
command: ["/app/provider", "8002"]
|
command: ["/app/provider", "8002"]
|
||||||
environment:
|
environment:
|
||||||
@@ -42,6 +48,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
BUILD_ID: ${CIE_AUTH_BUILD_ID:-dev}
|
||||||
|
BUILD_TIME_UTC: ${CIE_AUTH_BUILD_TIME_UTC:-unknown}
|
||||||
working_dir: /app/relying_party
|
working_dir: /app/relying_party
|
||||||
command: ["/app/relying_party", "8001"]
|
command: ["/app/relying_party", "8001"]
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from django.contrib import admin
|
|||||||
from django.urls import include, path, re_path
|
from django.urls import include, path, re_path
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
|
|
||||||
|
from scripts.build_probe import build_probe_view
|
||||||
from spid_cie_oidc.entity.urls import urlpatterns as entity_urlpatterns
|
from spid_cie_oidc.entity.urls import urlpatterns as entity_urlpatterns
|
||||||
from spid_cie_oidc.authority.urls import urlpatterns as ta_urlpatterns
|
from spid_cie_oidc.authority.urls import urlpatterns as ta_urlpatterns
|
||||||
from spid_cie_oidc.onboarding.urls import urlpatterns as onb_urlpatterns
|
from spid_cie_oidc.onboarding.urls import urlpatterns as onb_urlpatterns
|
||||||
@@ -39,6 +40,7 @@ urlpatterns.extend(onb_urlpatterns)
|
|||||||
urlpatterns.extend(
|
urlpatterns.extend(
|
||||||
(
|
(
|
||||||
path(f"{ADMIN_PATH}", admin.site.urls),
|
path(f"{ADMIN_PATH}", admin.site.urls),
|
||||||
|
path("__build", lambda request: build_probe_view("federation-authority"), name="build_probe"),
|
||||||
re_path('^static/(?P<path>.*)$',
|
re_path('^static/(?P<path>.*)$',
|
||||||
serve, {
|
serve, {
|
||||||
'document_root': settings.STATIC_ROOT,
|
'document_root': settings.STATIC_ROOT,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from django.contrib import admin
|
|||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
from django.urls import include, path, re_path
|
from django.urls import include, path, re_path
|
||||||
|
|
||||||
|
from scripts.build_probe import build_probe_view
|
||||||
from spid_cie_oidc.entity.urls import urlpatterns as entity_urlpatterns
|
from spid_cie_oidc.entity.urls import urlpatterns as entity_urlpatterns
|
||||||
|
|
||||||
admin.site.site_header = "OIDC Federation Provider Administration"
|
admin.site.site_header = "OIDC Federation Provider Administration"
|
||||||
@@ -29,6 +30,7 @@ ADMIN_PATH = getattr(settings, 'ADMIN_PATH', 'admin/')
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(f"{ADMIN_PATH}", admin.site.urls),
|
path(f"{ADMIN_PATH}", admin.site.urls),
|
||||||
|
path("__build", lambda request: build_probe_view("provider"), name="build_probe"),
|
||||||
re_path('^static/(?P<path>.*)$',
|
re_path('^static/(?P<path>.*)$',
|
||||||
serve, {
|
serve, {
|
||||||
'document_root': settings.STATIC_ROOT,
|
'document_root': settings.STATIC_ROOT,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from django.contrib import admin
|
|||||||
from django.urls import include, path, re_path
|
from django.urls import include, path, re_path
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
|
|
||||||
|
from scripts.build_probe import build_probe_view
|
||||||
from spid_cie_oidc.entity.urls import urlpatterns as ta_urlpatterns
|
from spid_cie_oidc.entity.urls import urlpatterns as ta_urlpatterns
|
||||||
from .visione_views import VisioneCompleteView, VisioneStartView
|
from .visione_views import VisioneCompleteView, VisioneStartView
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ ADMIN_PATH = getattr(settings, 'ADMIN_PATH', 'admin/')
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(f"{ADMIN_PATH}", admin.site.urls),
|
path(f"{ADMIN_PATH}", admin.site.urls),
|
||||||
|
path("__build", lambda request: build_probe_view("relying-party"), name="build_probe"),
|
||||||
path("visione/start", VisioneStartView.as_view(), name="visione_start"),
|
path("visione/start", VisioneStartView.as_view(), name="visione_start"),
|
||||||
path("visione/complete", VisioneCompleteView.as_view(), name="visione_complete"),
|
path("visione/complete", VisioneCompleteView.as_view(), name="visione_complete"),
|
||||||
re_path('^static/(?P<path>.*)$',
|
re_path('^static/(?P<path>.*)$',
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from django.http import JsonResponse
|
||||||
|
|
||||||
|
|
||||||
|
def build_probe_view(service: str):
|
||||||
|
info_path = Path("/app/__buildinfo__.json")
|
||||||
|
info = {}
|
||||||
|
if info_path.exists():
|
||||||
|
try:
|
||||||
|
info = json.loads(info_path.read_text())
|
||||||
|
except Exception:
|
||||||
|
info = {}
|
||||||
|
|
||||||
|
return JsonResponse(
|
||||||
|
{
|
||||||
|
"ok": True,
|
||||||
|
"service": service,
|
||||||
|
"build_id": info.get("build_id", ""),
|
||||||
|
"built_at_utc": info.get("built_at_utc", ""),
|
||||||
|
"image_marker": info.get("image_marker", ""),
|
||||||
|
"hostname": os.getenv("HOSTNAME", ""),
|
||||||
|
}
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user