pagezyhf HF Staff commited on
Commit
aa37823
·
1 Parent(s): ea6172d
Files changed (3) hide show
  1. Dockerfile +5 -2
  2. app/main.py +11 -2
  3. docker-compose.yml +1 -1
Dockerfile CHANGED
@@ -11,9 +11,12 @@ RUN apt-get update && apt-get install -y \
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
- # Copy the rest of the application
15
  COPY app/ ./app/
16
 
 
 
 
17
  # Set environment variables
18
  ENV PORT=7860
19
  ENV HOST=0.0.0.0
@@ -22,4 +25,4 @@ ENV HOST=0.0.0.0
22
  EXPOSE 7860
23
 
24
  # Command to run the application
25
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Copy the application
15
  COPY app/ ./app/
16
 
17
+ # Verify static files are present
18
+ RUN ls -la /app/app/static/css && ls -la /app/app/static/js
19
+
20
  # Set environment variables
21
  ENV PORT=7860
22
  ENV HOST=0.0.0.0
 
25
  EXPOSE 7860
26
 
27
  # Command to run the application
28
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]
app/main.py CHANGED
@@ -23,9 +23,13 @@ app = FastAPI()
23
  static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
24
  logger.info(f"Static directory path: {static_dir}")
25
 
 
 
 
 
26
  # Mount static files and templates
27
  app.mount("/static", StaticFiles(directory=static_dir), name="static")
28
- templates = Jinja2Templates(directory="app/templates")
29
 
30
  @app.get("/health")
31
  async def health_check():
@@ -88,4 +92,9 @@ async def get_model_info_endpoint(model_id: str):
88
  return JSONResponse(
89
  status_code=500,
90
  content={"error": str(e)}
91
- )
 
 
 
 
 
 
23
  static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
24
  logger.info(f"Static directory path: {static_dir}")
25
 
26
+ # Get the absolute path to the templates directory
27
+ templates_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
28
+ logger.info(f"Templates directory path: {templates_dir}")
29
+
30
  # Mount static files and templates
31
  app.mount("/static", StaticFiles(directory=static_dir), name="static")
32
+ templates = Jinja2Templates(directory=templates_dir)
33
 
34
  @app.get("/health")
35
  async def health_check():
 
92
  return JSONResponse(
93
  status_code=500,
94
  content={"error": str(e)}
95
+ )
96
+
97
+ @app.get("/static/{path:path}")
98
+ async def static_files(path: str):
99
+ logger.info(f"Static file requested: {path}")
100
+ return await app.mount("/static", StaticFiles(directory=static_dir), name="static")
docker-compose.yml CHANGED
@@ -7,7 +7,7 @@ services:
7
  environment:
8
  - HF_TOKEN=${HF_TOKEN}
9
  volumes:
10
- - ./app:/app/app
11
  - cache_data:/cache
12
 
13
  volumes:
 
7
  environment:
8
  - HF_TOKEN=${HF_TOKEN}
9
  volumes:
10
+ - ./app:/app/app:ro
11
  - cache_data:/cache
12
 
13
  volumes: