Robaa commited on
Commit
ab0f90e
·
verified ·
1 Parent(s): dfc7311

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +10 -47
dockerfile CHANGED
@@ -1,53 +1,16 @@
1
- # Stage 1: Builder for Python dependencies
2
- FROM python:3.11-slim as builder
3
 
4
- WORKDIR /app
5
-
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- build-essential \
8
- python3-dev \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- COPY requirements.txt .
12
- RUN pip install --user --no-cache-dir -r requirements.txt
13
 
14
- # Stage 2: Runtime image
15
- FROM python:3.11-slim
 
16
 
17
  WORKDIR /app
18
 
19
- RUN apt-get update && apt-get install -y --no-install-recommends \
20
- libgl1 \
21
- libglib2.0-0 \
22
- curl \
23
- && rm -rf /var/lib/apt/lists/*
24
-
25
- COPY --from=builder /root/.local /root/.local
26
-
27
- ENV PATH=/root/.local/bin:$PATH \
28
- PYTHONUNBUFFERED=1 \
29
- PYTHONPATH=/app \
30
- TF_CPP_MIN_LOG_LEVEL=3 \
31
- TF_ENABLE_ONEDNN_OPTS=0
32
-
33
- RUN mkdir -p /app/model_cache /app/temp_models \
34
- && chmod -R a+rwx /app/model_cache /app/temp_models
35
-
36
- ENV HF_HOME=/app/model_cache \
37
- XDG_CACHE_HOME=/app/model_cache \
38
- TEMP_MODEL_DIR=/app/temp_models
39
-
40
- COPY . .
41
-
42
- # Hugging Face requires port 7860
43
- EXPOSE 7860
44
-
45
- HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
46
- CMD curl -f http://localhost:7860/status/ || exit 1
47
-
48
- RUN useradd -m appuser \
49
- && chown -R appuser:appuser /app \
50
- && chmod -R a+rwx /app/model_cache /app/temp_models
51
- USER appuser
52
 
53
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
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 ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]