Skip to content

Commit 8305daf

Browse files
committed
Launch uvicorn from python
1 parent f783636 commit 8305daf

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ COPY --from=python_cache /venv /venv
3333
COPY --from=node_builder /frontend/dist /app/frontend/dist
3434
COPY backend backend
3535
WORKDIR /app/backend
36-
CMD uvicorn main:app --host "$HOST_PRIVATE" --port "$HOST_PORT"
36+
CMD ["python3", "main.py"]

backend/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from fastapi import FastAPI, Request
44
from fastapi.responses import FileResponse
55
from fastapi.staticfiles import StaticFiles
6+
import uvicorn
67

7-
from config import HOST_SUBPATH
8+
from config import HOST_PORT, HOST_PRIVATE, HOST_SUBPATH
89
from routes.auth import router as auth_router
910
from routes.courses import router as course_router
1011
from routes.members import router as members_router
@@ -59,3 +60,13 @@ async def diagnostics(request: Request):
5960

6061
# serve frontend
6162
app.mount("/", StaticFiles(directory=FRONTEND_PATH, html=True), "frontend")
63+
64+
if __name__ == "__main__":
65+
# forwarded_allow_ips set to * so that the nginx headers are trusted
66+
uvicorn.run(
67+
"main:app",
68+
host=HOST_PRIVATE,
69+
port=HOST_PORT,
70+
proxy_headers=True,
71+
forwarded_allow_ips="*",
72+
)

0 commit comments

Comments
 (0)