update
This commit is contained in:
parent
3d344b86ac
commit
12eaeb4351
4 changed files with 23 additions and 13 deletions
|
|
@ -25,8 +25,8 @@ RUN mkdir -p /app/data
|
|||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Add healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
# Add healthcheck with longer start period for initialization
|
||||
HEALTHCHECK --interval=10s --timeout=5s --start-period=40s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()" || exit 1
|
||||
|
||||
EXPOSE 8000
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import os
|
||||
|
||||
from sqlmodel import Session, SQLModel, create_engine # type: ignore
|
||||
|
||||
DATABASE_URL = "sqlite:///./notes.db"
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./notes.db")
|
||||
|
||||
engine = create_engine(
|
||||
DATABASE_URL, echo=True, connect_args={"check_same_thread": False}
|
||||
)
|
||||
# Only use check_same_thread for SQLite
|
||||
connect_args = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {}
|
||||
|
||||
engine = create_engine(DATABASE_URL, echo=True, connect_args=connect_args)
|
||||
|
||||
|
||||
def create_db_and_tables():
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
from fastapi import FastAPI # type: ignore
|
||||
from fastapi.middleware.cors import CORSMiddleware # type:ignore
|
||||
|
||||
|
|
@ -6,13 +8,11 @@ from app.routes import auth, folders, notes, tags
|
|||
|
||||
app = FastAPI(title="Notes API")
|
||||
|
||||
# CORS - adjust origins for production
|
||||
# CORS - configure via environment variable
|
||||
cors_origins = os.getenv("CORS_ORIGINS", "http://localhost:80").split(",")
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
"http://localhost:80",
|
||||
"https://notes.fitzythe.dev",
|
||||
], # Vite dev server
|
||||
allow_origins=cors_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
|
@ -33,3 +33,9 @@ app.include_router(tags.router, prefix="/api")
|
|||
@app.get("/")
|
||||
def root():
|
||||
return {"message": "Notes API"}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
"""Health check endpoint for Docker and Coolify"""
|
||||
return {"status": "healthy"}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ services:
|
|||
"-c",
|
||||
"import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()",
|
||||
]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
start_period: 40s
|
||||
retries: 3
|
||||
|
||||
ui:
|
||||
|
|
|
|||
Loading…
Reference in a new issue