MahmoudElsamadony commited on
Commit
a8fef8c
·
1 Parent(s): e79a4f5

FIX numpy not installed yet

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -0
  2. nginx.conf +7 -10
  3. start.sh +4 -1
Dockerfile CHANGED
@@ -12,6 +12,8 @@ RUN apt-get update && apt-get install -y \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  COPY requirements.txt .
 
 
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  COPY . .
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
  COPY requirements.txt .
15
+ # Install numpy and cython first to fix pyworld build issues
16
+ RUN pip install --no-cache-dir numpy==1.23.5 cython
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
  COPY . .
nginx.conf CHANGED
@@ -17,26 +17,23 @@ http {
17
  types_hash_max_size 2048;
18
 
19
  server {
20
- listen 7860;
21
- server_name localhost;
22
 
23
  # Increase body size for audio uploads if needed
24
  client_max_body_size 50M;
25
 
26
  # Route /api requests to FastAPI
27
- # Using ^~ to ensure this block takes precedence
28
- location ^~ /api/ {
29
- # Rewrite /api/xyz to /xyz
30
- rewrite ^/api/(.*) /$1 break;
31
-
32
- proxy_pass http://127.0.0.1:8000;
33
  proxy_set_header Host $host;
34
  proxy_set_header X-Real-IP $remote_addr;
35
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
36
  proxy_set_header X-Forwarded-Proto $scheme;
37
 
38
  # Debug header
39
- add_header X-Backend "FastAPI";
40
  }
41
 
42
  # Route everything else to Streamlit
@@ -54,7 +51,7 @@ http {
54
  proxy_read_timeout 86400;
55
 
56
  # Debug header
57
- add_header X-Backend "Streamlit";
58
  }
59
  }
60
  }
 
17
  types_hash_max_size 2048;
18
 
19
  server {
20
+ listen 7860 default_server;
21
+ server_name _;
22
 
23
  # Increase body size for audio uploads if needed
24
  client_max_body_size 50M;
25
 
26
  # Route /api requests to FastAPI
27
+ # The trailing slash in proxy_pass automatically strips /api/
28
+ location /api/ {
29
+ proxy_pass http://127.0.0.1:8000/;
 
 
 
30
  proxy_set_header Host $host;
31
  proxy_set_header X-Real-IP $remote_addr;
32
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33
  proxy_set_header X-Forwarded-Proto $scheme;
34
 
35
  # Debug header
36
+ add_header X-Backend "FastAPI" always;
37
  }
38
 
39
  # Route everything else to Streamlit
 
51
  proxy_read_timeout 86400;
52
 
53
  # Debug header
54
+ add_header X-Backend "Streamlit" always;
55
  }
56
  }
57
  }
start.sh CHANGED
@@ -1,7 +1,10 @@
1
  #!/bin/bash
2
 
 
 
 
 
3
  # Start FastAPI in the background
4
- # Removed --root-path since Nginx now handles the rewrite
5
  uvicorn api_server:app --host 0.0.0.0 --port 8000 &
6
 
7
  # Start Streamlit in the background
 
1
  #!/bin/bash
2
 
3
+ # Unset PORT so apps don't get confused by HF's default 7860
4
+ # We want Nginx to own port 7860, not Streamlit or Uvicorn
5
+ unset PORT
6
+
7
  # Start FastAPI in the background
 
8
  uvicorn api_server:app --host 0.0.0.0 --port 8000 &
9
 
10
  # Start Streamlit in the background