AronWolverine commited on
Commit
a9de418
·
verified ·
1 Parent(s): c373b1f

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +13 -7
dockerfile CHANGED
@@ -1,17 +1,23 @@
1
  # Use official Python runtime
2
  FROM python:3.9
3
 
4
- # Set the working directory
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy application files
8
- COPY . .
 
9
 
10
- # Install dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Expose the correct port for FastAPI
14
  EXPOSE 7860
15
 
16
- # Run the FastAPI app with Uvicorn
17
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Use official Python runtime
2
  FROM python:3.9
3
 
4
+ # Create and switch to a non-root user
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+ ENV PATH="/home/user/.local/bin:$PATH"
8
+
9
+ # Set working directory inside container
10
  WORKDIR /app
11
 
12
+ # Copy requirements file and install dependencies
13
+ COPY --chown=user ./requirements.txt requirements.txt
14
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
 
16
+ # Copy the entire app code
17
+ COPY --chown=user . /app
18
 
19
+ # Expose port 7860 (used by Hugging Face Spaces)
20
  EXPOSE 7860
21
 
22
+ # Run FastAPI app with Uvicorn
23
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]