fix: persist avatar data and uploads
This commit is contained in:
@@ -2,3 +2,5 @@ node_modules
|
|||||||
dist
|
dist
|
||||||
.env
|
.env
|
||||||
*.log
|
*.log
|
||||||
|
backend/avatar.db
|
||||||
|
backend/routers/uploads/
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ from sqlalchemy.orm import sessionmaker, declarative_base, Session
|
|||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
DB_FILE = os.path.join(BASE_DIR, "avatar.db")
|
DB_FILE = os.path.join(BASE_DIR, "avatar.db")
|
||||||
|
DATABASE_URL = os.getenv("DATABASE_URL", f"sqlite:///{DB_FILE}")
|
||||||
|
|
||||||
engine = create_engine(
|
engine = create_engine(
|
||||||
f"sqlite:///{DB_FILE}",
|
DATABASE_URL,
|
||||||
connect_args={"check_same_thread": False},
|
connect_args={"check_same_thread": False} if DATABASE_URL.startswith("sqlite:") else {},
|
||||||
)
|
)
|
||||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, expire_on_commit=False)
|
SessionLocal = sessionmaker(bind=engine, autoflush=False, expire_on_commit=False)
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import embeddings
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
UPLOAD_DIR = os.path.join(BASE_DIR, "uploads")
|
UPLOAD_DIR = os.path.abspath(os.getenv("UPLOAD_DIR", os.path.join(BASE_DIR, "uploads")))
|
||||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||||
|
|
||||||
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
|
ALLOWED_EXT = {".md", ".txt", ".pdf", ".doc", ".docx", ".xlsx"}
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: sqlite:////data/avatar.db
|
||||||
|
UPLOAD_DIR: /data/uploads
|
||||||
|
volumes:
|
||||||
|
- avatar-data:/data
|
||||||
expose:
|
expose:
|
||||||
- "8000"
|
- "8000"
|
||||||
ports:
|
ports:
|
||||||
@@ -29,3 +34,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
avatar-net:
|
avatar-net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
avatar-data:
|
||||||
|
|||||||
Reference in New Issue
Block a user