simran0608 commited on
Commit
e84543a
·
verified ·
1 Parent(s): 6736f11

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -6
Dockerfile CHANGED
@@ -6,6 +6,11 @@ WORKDIR /app
6
  RUN apt-get update && apt-get install -y \
7
  libgl1-mesa-glx \
8
  libglib2.0-0 \
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Copy the requirements file and install Python packages
@@ -15,6 +20,10 @@ RUN pip3 install --no-cache-dir -r requirements.txt
15
  # Copy ALL your application files from the root into the container's /app directory
16
  COPY . .
17
 
 
 
 
 
18
  # --- User and Permission Setup ---
19
  # Create a group and user
20
  RUN groupadd --system appuser && useradd --system --gid appuser appuser
@@ -28,15 +37,31 @@ ENV HOME=/app
28
  # Tell Ultralytics to use the /tmp directory for its config
29
  ENV YOLO_CONFIG_DIR=/tmp
30
 
 
 
 
 
 
 
31
  # Switch to the non-root user
32
  USER appuser
33
- # --- End of User Setup ---
34
 
 
 
 
 
35
  EXPOSE 8501
36
 
37
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
 
 
38
 
39
- # --- FINAL UPDATED ENTRYPOINT ---
40
- # Added `--server.headless=true` to make Streamlit compatible with the Hugging Face proxy.
41
- # This fixes the 403 Forbidden error on file uploads.
42
- ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false", "--server.headless=true"]
 
 
 
 
 
 
6
  RUN apt-get update && apt-get install -y \
7
  libgl1-mesa-glx \
8
  libglib2.0-0 \
9
+ libsm6 \
10
+ libxext6 \
11
+ libxrender-dev \
12
+ libgomp1 \
13
+ wget \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
  # Copy the requirements file and install Python packages
 
20
  # Copy ALL your application files from the root into the container's /app directory
21
  COPY . .
22
 
23
+ # --- FIXED: Ensure model file exists ---
24
+ # If you need to download the model, uncomment the next line:
25
+ # RUN wget -O best.pt "YOUR_MODEL_DOWNLOAD_URL"
26
+
27
  # --- User and Permission Setup ---
28
  # Create a group and user
29
  RUN groupadd --system appuser && useradd --system --gid appuser appuser
 
37
  # Tell Ultralytics to use the /tmp directory for its config
38
  ENV YOLO_CONFIG_DIR=/tmp
39
 
40
+ # --- FIXED: Set Hugging Face environment variables ---
41
+ ENV SPACE_ID=huggingface
42
+ ENV STREAMLIT_SERVER_HEADLESS=true
43
+ ENV STREAMLIT_SERVER_ENABLE_CORS=false
44
+ ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
45
+
46
  # Switch to the non-root user
47
  USER appuser
 
48
 
49
+ # --- FIXED: Create necessary directories ---
50
+ RUN mkdir -p /tmp/streamlit
51
+
52
+ # EXPOSE port
53
  EXPOSE 8501
54
 
55
+ # --- FIXED: Updated healthcheck ---
56
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
57
+ CMD curl -f http://localhost:8501/_stcore/health || exit 1
58
 
59
+ # --- FIXED: Updated entrypoint for Hugging Face Spaces ---
60
+ ENTRYPOINT ["streamlit", "run", "streamlit_app.py", \
61
+ "--server.port=8501", \
62
+ "--server.address=0.0.0.0", \
63
+ "--browser.gatherUsageStats=false", \
64
+ "--server.headless=true", \
65
+ "--server.enableCORS=false", \
66
+ "--server.enableXsrfProtection=false", \
67
+ "--server.maxUploadSize=200"]