Piyush1225 commited on
Commit
64c71a0
·
1 Parent(s): 4148d21

fix: HuggingFace Spaces Dockerfile - port 7860, user 1000

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -15
Dockerfile CHANGED
@@ -1,24 +1,18 @@
1
  FROM python:3.11-slim
2
 
3
- WORKDIR /app
 
 
4
 
5
- # Install build tools + runtime lib in one layer
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- build-essential \
8
- libpq-dev \
9
- && rm -rf /var/lib/apt/lists/*
10
 
11
- # Install dependencies directly into the image's Python (no prefix tricks)
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
 
15
- # Copy application source
16
- COPY . .
17
 
18
  ENV PYTHONDONTWRITEBYTECODE=1 \
19
  PYTHONUNBUFFERED=1 \
20
- PORT=8000
21
-
22
- EXPOSE 8000
23
 
24
- CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} --workers 1"]
 
1
  FROM python:3.11-slim
2
 
3
+ RUN useradd -m -u 1000 user
4
+ USER user
5
+ ENV PATH="/home/user/.local/bin:$PATH"
6
 
7
+ WORKDIR /app
 
 
 
 
8
 
9
+ COPY --chown=user ./requirements.txt requirements.txt
10
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
11
 
12
+ COPY --chown=user . /app
 
13
 
14
  ENV PYTHONDONTWRITEBYTECODE=1 \
15
  PYTHONUNBUFFERED=1 \
16
+ SECRET_KEY=hf-default-secret-change-me-in-settings
 
 
17
 
18
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]