Soumik Bose commited on
Commit
5011097
·
1 Parent(s): 360683b
Files changed (1) hide show
  1. Dockerfile +7 -13
Dockerfile CHANGED
@@ -1,11 +1,9 @@
1
- # UPDATE: Changed from 3.9 to 3.11 to support newer NumPy/Pandas versions
2
  FROM python:3.11-slim
3
 
4
- # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Install system dependencies
8
- # Added 'curl' explicitly to the list below
9
  RUN apt-get update && apt-get install -y \
10
  curl \
11
  tesseract-ocr \
@@ -24,33 +22,29 @@ RUN apt-get update && apt-get install -y \
24
  libglib2.0-0 \
25
  && rm -rf /var/lib/apt/lists/*
26
 
27
- # Upgrade pip, setuptools, and wheel before installing deps
28
  COPY requirements.txt .
29
  RUN pip install --upgrade pip setuptools wheel \
30
  && pip install --default-timeout=100 --retries=10 --no-cache-dir -r requirements.txt
31
 
32
- # Copy the current directory contents into the container
33
  COPY . .
34
 
35
- # Create a non-root user for security (Production Best Practice)
36
  RUN useradd -m appuser && chown -R appuser /app
37
  USER appuser
38
 
39
- # Set environment variables
40
  ENV HF_HOME=/tmp/cache
41
  ENV PORT=7860
 
 
 
42
 
43
- # Create cache directory (if still needed)
44
  RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME}
45
 
46
- # Expose port
47
  EXPOSE $PORT
48
 
49
- # Run FastAPI with Uvicorn
50
- # The curl command will now work because the package is installed
51
  CMD bash -c "\
52
  while true; do \
53
  curl -s https://xce009-ocr-api.hf.space/api/v1/ping >/dev/null; \
54
  sleep 300; \
55
  done & \
56
- uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 4"
 
1
+ # ... existing imports ...
2
  FROM python:3.11-slim
3
 
 
4
  WORKDIR /app
5
 
6
+ # ... existing apt-get installs ...
 
7
  RUN apt-get update && apt-get install -y \
8
  curl \
9
  tesseract-ocr \
 
22
  libglib2.0-0 \
23
  && rm -rf /var/lib/apt/lists/*
24
 
 
25
  COPY requirements.txt .
26
  RUN pip install --upgrade pip setuptools wheel \
27
  && pip install --default-timeout=100 --retries=10 --no-cache-dir -r requirements.txt
28
 
 
29
  COPY . .
30
 
 
31
  RUN useradd -m appuser && chown -R appuser /app
32
  USER appuser
33
 
 
34
  ENV HF_HOME=/tmp/cache
35
  ENV PORT=7860
36
+ # --- FIX: DISABLING BUFFERING ---
37
+ ENV PYTHONUNBUFFERED=1
38
+ # --------------------------------
39
 
 
40
  RUN mkdir -p ${HF_HOME} && chmod 777 ${HF_HOME}
41
 
 
42
  EXPOSE $PORT
43
 
44
+ # --- OPTIONAL: Added --log-level info to uvicorn ---
 
45
  CMD bash -c "\
46
  while true; do \
47
  curl -s https://xce009-ocr-api.hf.space/api/v1/ping >/dev/null; \
48
  sleep 300; \
49
  done & \
50
+ uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers 4 --log-level info"