iitmbs24f commited on
Commit
93fd625
·
verified ·
1 Parent(s): e062d38

Upload 17 files

Browse files
Files changed (4) hide show
  1. Dockerfile +9 -6
  2. app.py +3 -2
  3. docker-compose.yml +3 -3
  4. start.sh +12 -0
Dockerfile CHANGED
@@ -23,12 +23,15 @@ RUN useradd --create-home --shell /bin/bash app \
23
  && chown -R app:app /app
24
  USER app
25
 
26
- # Expose port
27
- EXPOSE 8000
28
 
29
- # Health check
30
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
31
- CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
32
 
33
- # Start command
34
- CMD ["python", "main.py"]
 
 
 
 
23
  && chown -R app:app /app
24
  USER app
25
 
26
+ # Expose port for Hugging Face Spaces
27
+ EXPOSE 7860
28
 
29
+ # Health check for Hugging Face Spaces
30
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
31
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
32
 
33
+ # Make startup script executable
34
+ RUN chmod +x start.sh
35
+
36
+ # Start command for Hugging Face Spaces
37
+ CMD ["./start.sh"]
app.py CHANGED
@@ -353,12 +353,13 @@ async def internal_error_handler(request, exc):
353
  if __name__ == "__main__":
354
  import uvicorn
355
 
 
356
  host = os.getenv("HOST", "0.0.0.0")
357
- port = int(os.getenv("PORT", 8000))
358
  debug = os.getenv("DEBUG", "false").lower() == "true"
359
 
360
  uvicorn.run(
361
- "app:app",
362
  host=host,
363
  port=port,
364
  reload=debug,
 
353
  if __name__ == "__main__":
354
  import uvicorn
355
 
356
+ # Hugging Face Spaces configuration
357
  host = os.getenv("HOST", "0.0.0.0")
358
+ port = int(os.getenv("PORT", 7860)) # Hugging Face Spaces default port
359
  debug = os.getenv("DEBUG", "false").lower() == "true"
360
 
361
  uvicorn.run(
362
+ app, # Use the app object directly
363
  host=host,
364
  port=port,
365
  reload=debug,
docker-compose.yml CHANGED
@@ -4,7 +4,7 @@ services:
4
  llm-deployment:
5
  build: .
6
  ports:
7
- - "8000:8000"
8
  environment:
9
  - OPENAI_API_KEY=${OPENAI_API_KEY}
10
  - OPENAI_MODEL=${OPENAI_MODEL}
@@ -12,13 +12,13 @@ services:
12
  - GITHUB_USERNAME=${GITHUB_USERNAME}
13
  - SHARED_SECRET=${SHARED_SECRET}
14
  - HOST=0.0.0.0
15
- - PORT=8000
16
  - DEBUG=false
17
  volumes:
18
  - ./logs:/app/logs
19
  restart: unless-stopped
20
  healthcheck:
21
- test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
22
  interval: 30s
23
  timeout: 10s
24
  retries: 3
 
4
  llm-deployment:
5
  build: .
6
  ports:
7
+ - "7860:7860"
8
  environment:
9
  - OPENAI_API_KEY=${OPENAI_API_KEY}
10
  - OPENAI_MODEL=${OPENAI_MODEL}
 
12
  - GITHUB_USERNAME=${GITHUB_USERNAME}
13
  - SHARED_SECRET=${SHARED_SECRET}
14
  - HOST=0.0.0.0
15
+ - PORT=7860
16
  - DEBUG=false
17
  volumes:
18
  - ./logs:/app/logs
19
  restart: unless-stopped
20
  healthcheck:
21
+ test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"]
22
  interval: 30s
23
  timeout: 10s
24
  retries: 3
start.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Hugging Face Spaces startup script
4
+ echo "Starting LLM Code Deployment API..."
5
+
6
+ # Set environment variables for Hugging Face Spaces
7
+ export HOST=0.0.0.0
8
+ export PORT=7860
9
+ export DEBUG=false
10
+
11
+ # Start the application
12
+ python app.py