Maouu commited on
Commit
a379324
·
verified ·
1 Parent(s): 7397a82

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -7
Dockerfile CHANGED
@@ -1,16 +1,28 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
 
4
- FROM python:3.9
 
 
 
5
 
 
6
  RUN useradd -m -u 1000 user
7
  USER user
8
- ENV PATH="/home/user/.local/bin:$PATH"
9
 
 
 
10
  WORKDIR /app
11
 
12
- COPY --chown=user ./requirements.txt requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
14
 
 
15
  COPY --chown=user . /app
16
- CMD ["gunicorn", "app:app", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:7860", "--workers", "3", "--timeout", "90"]
 
 
 
 
 
 
1
+ FROM python:3.9-slim
 
2
 
3
+ # System dependencies
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ build-essential gcc libffi-dev libpq-dev curl && \
6
+ apt-get clean && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Create and switch to non-root user
9
  RUN useradd -m -u 1000 user
10
  USER user
 
11
 
12
+ # Set environment
13
+ ENV PATH="/home/user/.local/bin:$PATH"
14
  WORKDIR /app
15
 
16
+ # Copy requirements and install
17
+ COPY --chown=user requirements.txt .
18
+ RUN pip install --no-cache-dir --upgrade pip && \
19
+ pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Copy source code
22
  COPY --chown=user . /app
23
+
24
+ # Expose port (optional for readability)
25
+ EXPOSE 7860
26
+
27
+ # Use Uvicorn with proper worker class if using FastAPI or async
28
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]