Skip to content

Commit

Permalink
Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
machado2 committed Jun 30, 2024
1 parent 493cec2 commit e6d3262
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
venv
.venv
.idea
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
__pycache__
/app/settings.py
/settings.py
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "main.py"]
4 changes: 2 additions & 2 deletions app/aihorde_image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tortoise import Tortoise

from app.settings import TORTOISE_ORM
from settings import TORTOISE_ORM


async def init():
Expand Down
2 changes: 1 addition & 1 deletion app/image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
web:
build: .
ports:
- "8000:8000"
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
from contextlib import asynccontextmanager

Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tool.aerich]
tortoise_orm = "app.settings.TORTOISE_ORM"
tortoise_orm = "settings.TORTOISE_ORM"
location = "./migrations"
src_folder = "./."
22 changes: 22 additions & 0 deletions settings.py.example
Original file line number Diff line number Diff line change
@@ -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)"

0 comments on commit e6d3262

Please sign in to comment.