diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..24b6e81 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +venv +.venv +.idea diff --git a/.gitignore b/.gitignore index 03abc34..eab850b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea __pycache__ /app/settings.py +/settings.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5290073 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python +WORKDIR /app +COPY requirements.txt . +RUN pip install -r requirements.txt +COPY . . +EXPOSE 8000 +CMD ["python", "main.py"] \ No newline at end of file diff --git a/app/aihorde_image_generator.py b/app/aihorde_image_generator.py index f38d485..e8a7461 100644 --- a/app/aihorde_image_generator.py +++ b/app/aihorde_image_generator.py @@ -6,8 +6,8 @@ import requests from PIL import Image -from app.settings import AI_HORDE_API_KEY -from app.settings import SD_MODEL +from settings import AI_HORDE_API_KEY +from settings import SD_MODEL class AiHordeImageGenerator: diff --git a/app/db.py b/app/db.py index 9cb3893..8193c7c 100644 --- a/app/db.py +++ b/app/db.py @@ -1,6 +1,6 @@ from tortoise import Tortoise -from app.settings import TORTOISE_ORM +from settings import TORTOISE_ORM async def init(): diff --git a/app/image_generator.py b/app/image_generator.py index 3d1a159..39aaae6 100644 --- a/app/image_generator.py +++ b/app/image_generator.py @@ -3,7 +3,7 @@ from app.aihorde_image_generator import AiHordeImageGenerator from app.article_repository import ImageGenerated, ImageToCreate -from app.settings import SD_MODEL +from settings import SD_MODEL image_generator = AiHordeImageGenerator() diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9013cce --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +services: + web: + build: . + ports: + - "8000:8000" \ No newline at end of file diff --git a/main.py b/main.py index 949de03..704a457 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import logging import os from contextlib import asynccontextmanager @@ -13,6 +14,8 @@ from app.get_image import router as get_image_router from app.wait import router as wait_router +logging.basicConfig(level=logging.DEBUG) + @asynccontextmanager async def lifespan(_app: FastAPI): diff --git a/pyproject.toml b/pyproject.toml index 29b0ad1..f5d9e5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.aerich] -tortoise_orm = "app.settings.TORTOISE_ORM" +tortoise_orm = "settings.TORTOISE_ORM" location = "./migrations" src_folder = "./." diff --git a/settings.py.example b/settings.py.example new file mode 100644 index 0000000..e3a5bcb --- /dev/null +++ b/settings.py.example @@ -0,0 +1,22 @@ +TORTOISE_ORM = { + "connections": { + "default": { + "engine": "tortoise.backends.asyncpg", + "credentials": { + "database": *** + "host": *** + "user": *** + "password": *** + } + } + }, + "apps": { + "models": { + "models": ["app.models", "aerich.models"], + "default_connection": "default", + } + }, +} + +AI_HORDE_API_KEY = *** +SD_MODEL = "AlbedoBase XL (SDXL)"