Pujan-Dev commited on
Commit
098e8c5
·
1 Parent(s): c03128c

refact: docker update

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -28
Dockerfile CHANGED
@@ -1,40 +1,29 @@
1
- # Use official Python 3.10 image
2
- FROM python:3.10-slim
3
 
4
- # Install system dependencies (requires root)
5
- RUN apt-get update && \
6
- apt-get install -y --no-install-recommends \
7
- libgl1 \
8
- build-essential \
9
- curl \
10
- && apt-get clean && rm -rf /var/lib/apt/lists/*
11
-
12
- # Create non-root user
13
  RUN useradd -m -u 1000 user
14
 
15
- # Set environment for pip and path
16
- ENV PATH="/home/user/.local/bin:$PATH" \
17
- PYTHONDONTWRITEBYTECODE=1 \
18
- PYTHONUNBUFFERED=1
19
 
20
- # Switch to the user
21
  USER user
22
- WORKDIR /app
23
 
24
- # Copy and install requirements
25
- COPY --chown=user requirements.txt .
26
- RUN pip install --no-cache-dir --upgrade pip && \
27
- pip install --no-cache-dir -r requirements.txt
28
 
29
- # Ensure spaCy model is installed (safe fallback if download fails)
30
- RUN python -m spacy download en_core_web_sm || echo "spaCy model download failed, continuing..."
31
 
32
- # Copy rest of the app
33
- COPY --chown=user . .
 
34
 
35
- # Expose port (optional but good practice)
36
- EXPOSE 7860
37
 
38
- # Start the app
39
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
40
 
 
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.10
5
+
6
+ # Create user first
 
 
 
 
 
 
7
  RUN useradd -m -u 1000 user
8
 
9
+ # Install system dependencies (requires root)
10
+ RUN apt-get update && apt-get install -y libgl1
 
 
11
 
12
+ # Switch to non-root user
13
  USER user
14
+ ENV PATH="/home/user/.local/bin:$PATH"
15
 
16
+ # Add TensorFlow environment variables to reduce logging noise
17
+ ENV TF_CPP_MIN_LOG_LEVEL=2
18
+ ENV TF_ENABLE_ONEDNN_OPTS=0
 
19
 
20
+ WORKDIR /app
 
21
 
22
+ COPY --chown=user ./requirements.txt requirements.txt
23
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
24
+ RUN python -m spacy download en_core_web_sm || echo "Failed to download model"
25
 
26
+ COPY --chown=user . /app
 
27
 
 
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
29