File size: 853 Bytes
1278df1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Launch the FastAPI backend and Streamlit UI in one Docker container."""

from __future__ import annotations

import subprocess
import sys


def main() -> int:
    """Start the API backend in the background and keep Streamlit in the foreground."""

    api_process = subprocess.Popen(
        ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8001"],
    )
    try:
        return subprocess.call(
            [
                "streamlit",
                "run",
                "app/streamlit_app.py",
                "--server.port",
                "8000",
                "--server.address",
                "0.0.0.0",
                "--server.headless",
                "true",
            ]
        )
    finally:
        api_process.terminate()
        api_process.wait(timeout=10)


if __name__ == "__main__":
    sys.exit(main())