NoLev commited on
Commit
30b84fa
·
verified ·
1 Parent(s): 0fe34c8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -29
Dockerfile CHANGED
@@ -1,43 +1,24 @@
1
- # Use official Python 3.10 slim image as base
2
- FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Set environment variables
8
- ENV PYTHONUNBUFFERED=1
9
- # For app logging
10
- ENV LOG_LEVEL=debug
11
-
12
- # Install system dependencies
13
  RUN apt-get update && apt-get install -y \
14
  gcc \
15
- g++ \
16
- libmariadb-dev-compat \
17
- && apt-get clean \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
- # Copy requirements.txt
21
  COPY requirements.txt .
22
-
23
- # Install Python dependencies
24
- RUN pip install --no-cache-dir -r requirements.txt
25
 
26
  # Copy application code
27
- COPY app/main.py ./app/main.py
28
- COPY static/index.html ./static/index.html
29
-
30
- # Create cache directories and set permissions
31
- RUN mkdir -p /app/hf_cache \
32
- && chmod -R 777 /app/hf_cache
33
-
34
- # Create a non-root user and switch to it
35
- RUN useradd -m -u 1000 appuser \
36
- && chown -R appuser:appuser /app
37
- USER appuser
38
 
39
- # Expose port 7860 for Hugging Face Spaces
40
  EXPOSE 7860
41
 
42
- # Run the FastAPI app with Uvicorn in debug mode
43
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]
 
1
+ # Use Python 3.12 slim for efficiency (CPU-only for torch)
2
+ FROM python:3.12-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies (for PDF handling and build tools)
 
 
 
 
 
8
  RUN apt-get update && apt-get install -y \
9
  gcc \
 
 
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy and install Python dependencies
13
  COPY requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt \
15
+ && pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
 
16
 
17
  # Copy application code
18
+ COPY . .
 
 
 
 
 
 
 
 
 
 
19
 
20
+ # Expose port (from your uvicorn config)
21
  EXPOSE 7860
22
 
23
+ # Run the app
24
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]