diff --git a/docker/build.dockerfile b/docker/build.dockerfile index 5299c54..db86dc7 100644 --- a/docker/build.dockerfile +++ b/docker/build.dockerfile @@ -28,6 +28,8 @@ ENV VENV_PATH=/opt/venv COPY --from=build-image $VENV_PATH $VENV_PATH ENV PATH="$VENV_PATH/bin:$PATH" +COPY ./scripts/healthcheck.py /root/ + EXPOSE 8080 WORKDIR /app/ diff --git a/scripts/healthcheck.py b/scripts/healthcheck.py new file mode 100644 index 0000000..e21d83a --- /dev/null +++ b/scripts/healthcheck.py @@ -0,0 +1,11 @@ +import os + +import httpx + + +response = httpx.get( + "http://localhost:8080/healthcheck", + headers={"Authorization": os.environ["API_KEY"]}, +) +print(f"HEALTHCHECK STATUS: {response.status_code}") +exit(0 if response.status_code == 200 else 1) diff --git a/src/app/views.py b/src/app/views.py index 865fc21..5c7b0e9 100644 --- a/src/app/views.py +++ b/src/app/views.py @@ -28,3 +28,8 @@ async def get_filename(book_id: int, file_type: str): book = await BookLibraryClient.get_book(book_id) return _get_filename(book.remote_id, book, file_type) + + +@router.get("/healthcheck") +async def healthcheck(): + return "Ok!"