norhan12 commited on
Commit
9f50dc7
·
verified ·
1 Parent(s): 008ef04

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -14
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
  FROM python:3.10-slim
2
 
3
- # 1. Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  libsndfile1 \
6
  ffmpeg \
@@ -13,10 +13,10 @@ RUN apt-get update && apt-get install -y \
13
  build-essential \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # 2. Create non-root user
17
  RUN useradd -m appuser
18
 
19
- # 3. Create directory structure
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
@@ -26,32 +26,33 @@ RUN mkdir -p \
26
  /app/assets && \
27
  chown -R appuser:appuser /app /tmp/matplotlib /tmp/fontconfig /tmp/lhotse
28
 
29
- # 4. Set working directory
30
  WORKDIR /app
31
 
32
- # 5. Copy application files
33
  COPY --chown=appuser:appuser . .
34
 
35
- # 6. Set environment variables
36
  ENV MPLCONFIGDIR=/tmp/matplotlib \
37
  FONTCONFIG_PATH=/tmp/fontconfig \
38
  LHOTSE_CACHE_DIR=/tmp/lhotse \
39
  HF_HUB_ENABLE_HF_TRANSFER=1 \
40
  PYTHONUNBUFFERED=1
41
 
42
- # 7. Install Python dependencies
43
  USER appuser
44
  RUN pip install --upgrade pip && \
45
  pip install --no-cache-dir -r requirements.txt && \
46
  python -m spacy download en_core_web_sm && \
47
  pip check
48
 
49
- # 8. Expose Flask port
50
- EXPOSE 5000
51
 
52
- # 9. Health check (fixed for Flask)
53
- HEALTHCHECK --interval=30s --timeout=10s \
54
- CMD curl -f http://localhost:5000/ || exit 1
55
 
56
- # 10. Run the application
57
- CMD ["python", "app.py"]
 
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  libsndfile1 \
6
  ffmpeg \
 
13
  build-essential \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Create non-root user
17
  RUN useradd -m appuser
18
 
19
+ # Create directory structure
20
  RUN mkdir -p \
21
  /tmp/matplotlib \
22
  /tmp/fontconfig \
 
26
  /app/assets && \
27
  chown -R appuser:appuser /app /tmp/matplotlib /tmp/fontconfig /tmp/lhotse
28
 
29
+ # Set working directory
30
  WORKDIR /app
31
 
32
+ # Copy application files
33
  COPY --chown=appuser:appuser . .
34
 
35
+ # Set environment variables
36
  ENV MPLCONFIGDIR=/tmp/matplotlib \
37
  FONTCONFIG_PATH=/tmp/fontconfig \
38
  LHOTSE_CACHE_DIR=/tmp/lhotse \
39
  HF_HUB_ENABLE_HF_TRANSFER=1 \
40
  PYTHONUNBUFFERED=1
41
 
42
+ # Install Python dependencies
43
  USER appuser
44
  RUN pip install --upgrade pip && \
45
  pip install --no-cache-dir -r requirements.txt && \
46
  python -m spacy download en_core_web_sm && \
47
  pip check
48
 
49
+ # Expose Flask port
50
+ EXPOSE 7860
51
 
52
+ # Hugging Face Spaces prefers your app runs on port 7860
53
+ ENV PORT 7860
 
54
 
55
+ # Startup delay safe healthcheck (اختياري لو حابة في future local deployment)
56
+
57
+ # Run using gunicorn (safer for prod)
58
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]