Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN chown -R app:app /app
USER app

# Expose port
EXPOSE 8000
EXPOSE 8080

# Run the application
CMD ["python", "run.py"]
19 changes: 15 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fastapi.responses import HTMLResponse
from starlette.middleware.sessions import SessionMiddleware
from contextlib import asynccontextmanager
import os
import time
from sqlalchemy import text
from sqlalchemy.exc import OperationalError
Expand All @@ -18,17 +19,26 @@
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup: wait for DB to be ready, then create tables
max_attempts = 30
max_attempts = int(os.environ.get("DB_BOOT_WAIT_ATTEMPTS", "30"))
sleep_seconds = float(os.environ.get("DB_BOOT_WAIT_SLEEP", "2"))
allow_start_without_db = os.environ.get("ALLOW_START_WITHOUT_DB", "false").lower() in {"1", "true", "yes"}

db_ready = False
for attempt in range(1, max_attempts + 1):
try:
with engine.connect() as conn:
conn.execute(text("SELECT 1"))
db_ready = True
break
except OperationalError:
if attempt == max_attempts:
if allow_start_without_db:
break
raise
time.sleep(2)
Base.metadata.create_all(bind=engine)
time.sleep(sleep_seconds)

if db_ready:
Base.metadata.create_all(bind=engine)
yield
# Shutdown
pass
Expand Down Expand Up @@ -84,9 +94,10 @@ async def health_check():
return {"status": "healthy", "message": "Shadiejo API is running"}

if __name__ == "__main__":
port = int(os.environ.get("PORT", "8080"))
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=8000,
port=port,
reload=True
)
16 changes: 6 additions & 10 deletions app/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
Startup script for Shadiejo FastAPI application
"""

import os
import uvicorn
from app.main import app

if __name__ == "__main__":
print("🚀 Starting Shadiejo FastAPI Application...")
print("📱 Frontend: http://localhost:8000")
print("📚 API Docs: http://localhost:8000/docs")
print("🔧 Admin Panel: http://localhost:8000/redoc")
print("📱 Frontend: http://localhost:8080")
print("📚 API Docs: http://localhost:8080/docs")
print("🔧 Admin Panel: http://localhost:8080/redoc")
print("=" * 50)

uvicorn.run(
app,
host="0.0.0.0",
port=8000,
reload=True,
log_level="info"
)
port = int(os.environ.get("PORT", "8080"))
uvicorn.run(app, host="0.0.0.0", port=port, reload=True, log_level="info")
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ services:

app:
build: .
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
command: uvicorn app.main:app --host 0.0.0.0 --port 8080
ports:
- "8000:8000"
- "8080:8080"
env_file:
- .env
environment:
Expand Down
16 changes: 6 additions & 10 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
Startup script for Shadiejo FastAPI application
"""

import os
import uvicorn
from app.main import app

if __name__ == "__main__":
print("🚀 Starting Shadiejo FastAPI Application...")
print("📱 Frontend: http://localhost:8000")
print("📚 API Docs: http://localhost:8000/docs")
print("🔧 Admin Panel: http://localhost:8000/redoc")
print("📱 Frontend: http://localhost:8080")
print("📚 API Docs: http://localhost:8080/docs")
print("🔧 Admin Panel: http://localhost:8080/redoc")
print("=" * 50)

uvicorn.run(
app,
host="0.0.0.0",
port=8000,
reload=True,
log_level="info"
)
port = int(os.environ.get("PORT", "8080"))
uvicorn.run(app, host="0.0.0.0", port=port, reload=True, log_level="info")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test_signup_flow.py → tests/test_signup_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def test_signup_flow():
"""Test the complete signup process"""
base_url = "http://localhost:8000"
base_url = "http://localhost:8080"

print("🚀 Testing Signup Flow with Email Verification")
print("=" * 50)
Expand Down
File renamed without changes.