diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..81209de --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.12 + +WORKDIR /src + +RUN apt-get update && apt-get install make +COPY Makefile requirements.lock pyproject.toml README.md /src/ +RUN make deps + +COPY . . + +CMD make run diff --git a/api/Makefile b/api/Makefile new file mode 100644 index 0000000..debd2bf --- /dev/null +++ b/api/Makefile @@ -0,0 +1,3 @@ +deps: + pip install uv + uv pip install --no-cache --system -r requirements.lock diff --git a/api/src/api/__init__.py b/api/src/api/__init__.py index 533cc6c..608bf50 100644 --- a/api/src/api/__init__.py +++ b/api/src/api/__init__.py @@ -1 +1,2 @@ -from .check_imei import checking_router as checking_router \ No newline at end of file +from .check_imei import checking_router as checking_router +from .healthcheck import healthcheck_router as healthcheck_router \ No newline at end of file diff --git a/api/src/api/healthcheck.py b/api/src/api/healthcheck.py new file mode 100644 index 0000000..5358ef3 --- /dev/null +++ b/api/src/api/healthcheck.py @@ -0,0 +1,8 @@ +from fastapi import APIRouter, status + +healthcheck_router = APIRouter() + + +@healthcheck_router.get("/healthcheck", status_code=status.HTTP_200_OK) +async def healthcheck(): + return None diff --git a/api/src/app.py b/api/src/app.py index 33b5a4c..0f45cbb 100644 --- a/api/src/app.py +++ b/api/src/app.py @@ -9,7 +9,7 @@ from src.utils.exceptions import ( ExternalDataValidationError ) -from src.api import checking_router +from src.api import checking_router, healthcheck_router app = FastAPI( title="hatiko-api", @@ -26,7 +26,7 @@ main_app_router = APIRouter(prefix="/api") main_app_router.include_router(checking_router, tags=["Check IMEI"]) - +app.include_router(healthcheck_router, tags=["Health"]) app.include_router(main_app_router) diff --git a/bot/Dockerfile b/bot/Dockerfile new file mode 100644 index 0000000..81209de --- /dev/null +++ b/bot/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.12 + +WORKDIR /src + +RUN apt-get update && apt-get install make +COPY Makefile requirements.lock pyproject.toml README.md /src/ +RUN make deps + +COPY . . + +CMD make run diff --git a/bot/Makefile b/bot/Makefile new file mode 100644 index 0000000..debd2bf --- /dev/null +++ b/bot/Makefile @@ -0,0 +1,3 @@ +deps: + pip install uv + uv pip install --no-cache --system -r requirements.lock diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..a1f0a47 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,21 @@ +name: hatiko + +services: + api: + container_name: hatiko-api + restart: always + build: ./api + env_file: .env + healthcheck: + test: curl -sSf http://localhost:8000/healthcheck + interval: 60s + start_period: 1s + timeout: 600s + ports: + - 8000:8000 + + bot: + container_name: hatiko-bot + restart: always + build: ./bot + env_file: .env \ No newline at end of file