uncertainrods commited on
Commit
c2f2dbc
·
verified ·
1 Parent(s): e97dd04

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -23
Dockerfile CHANGED
@@ -1,24 +1,30 @@
1
- # Use the official Python image
2
- FROM python:3.9
3
-
4
- # Set the working directory
5
- WORKDIR /code
6
-
7
- # Copy requirements and install them
8
- COPY ./requirements.txt /code/requirements.txt
9
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
10
-
11
- # Copy the application code
12
- COPY ./main.py /code/main.py
13
-
14
- # Create a non-root user (Security requirement for HF Spaces)
15
- RUN useradd -m -u 1000 user
16
- USER user
17
- ENV HOME=/home/user \
18
- PATH=/home/user/.local/bin:$PATH
19
-
20
- # Expose the port Hugging Face expects
21
- EXPOSE 7860
22
-
23
- # Command to run the app
 
 
 
 
 
 
24
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use the official Python 3.10 slim image
2
+ FROM python:3.10-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Set environment variables
8
+ # Prevents Python from writing .pyc files and ensures logs are flushed to terminal
9
+ ENV PYTHONDONTWRITEBYTECODE 1
10
+ ENV PYTHONUNBUFFERED 1
11
+
12
+ # Install system dependencies if needed (none required for this specific script)
13
+ # RUN apt-get update && apt-get install -y --no-install-recommends gcc
14
+
15
+ # Copy the requirements file first to leverage Docker cache
16
+ COPY requirements.txt .
17
+
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Copy the rest of the application code
22
+ COPY . .
23
+
24
+ # Hugging Face Spaces runs on port 7860 by default
25
+ # We expose this port for documentation
26
+ EXPOSE 7860
27
+
28
+ # Start the FastAPI application using uvicorn
29
+ # We use main:app (assuming your file is named main.py and the FastAPI instance is 'app')
30
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]