add docker system

This commit is contained in:
Ivanov Matvey 2025-01-24 18:33:52 +10:00
parent 44efa841a2
commit c0f7b030a6
8 changed files with 61 additions and 3 deletions

11
api/Dockerfile Normal file
View File

@ -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

3
api/Makefile Normal file
View File

@ -0,0 +1,3 @@
deps:
pip install uv
uv pip install --no-cache --system -r requirements.lock

View File

@ -1 +1,2 @@
from .check_imei import checking_router as checking_router from .check_imei import checking_router as checking_router
from .healthcheck import healthcheck_router as healthcheck_router

View File

@ -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

View File

@ -9,7 +9,7 @@ from src.utils.exceptions import (
ExternalDataValidationError ExternalDataValidationError
) )
from src.api import checking_router from src.api import checking_router, healthcheck_router
app = FastAPI( app = FastAPI(
title="hatiko-api", title="hatiko-api",
@ -26,7 +26,7 @@ main_app_router = APIRouter(prefix="/api")
main_app_router.include_router(checking_router, tags=["Check IMEI"]) main_app_router.include_router(checking_router, tags=["Check IMEI"])
app.include_router(healthcheck_router, tags=["Health"])
app.include_router(main_app_router) app.include_router(main_app_router)

11
bot/Dockerfile Normal file
View File

@ -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

3
bot/Makefile Normal file
View File

@ -0,0 +1,3 @@
deps:
pip install uv
uv pip install --no-cache --system -r requirements.lock

21
compose.yaml Normal file
View File

@ -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