nivakaran commited on
Commit
eb7c28e
·
verified ·
1 Parent(s): 3dc95dc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -6
Dockerfile CHANGED
@@ -1,17 +1,28 @@
1
- # Use Python 3.10 as base image
2
- FROM python:3.10.9
 
 
 
 
 
 
 
 
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Copy all files to container
8
- COPY . /app
9
 
10
  # Install Python dependencies
11
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
 
13
- # Expose port 7860 (Hugging Face Spaces default port)
 
 
 
14
  EXPOSE 7860
15
 
16
- # Run the FastAPI app
17
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use Python 3.11 (has SQLite 3.40+) instead of 3.10
2
+ FROM python:3.11-slim
3
+
4
+ # Create non-root user for security
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # Set environment variables
9
+ ENV PATH="/home/user/.local/bin:$PATH"
10
+ ENV PYTHONUNBUFFERED=1
11
 
12
  # Set working directory
13
  WORKDIR /app
14
 
15
+ # Copy requirements first for better caching
16
+ COPY --chown=user ./requirements.txt requirements.txt
17
 
18
  # Install Python dependencies
19
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
 
21
+ # Copy application files
22
+ COPY --chown=user . /app
23
+
24
+ # Expose port 7860 (Hugging Face Spaces requirement)
25
  EXPOSE 7860
26
 
27
+ # Run the FastAPI application
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]