Tirush12 commited on
Commit
d9b7c51
·
verified ·
1 Parent(s): 29e970e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -11
Dockerfile CHANGED
@@ -1,33 +1,38 @@
1
- # Use the official Python lightweight image
2
  FROM python:3.10-slim
3
 
4
- # 1. Install system dependencies (CRITICAL for OpenCV/cv2)
5
- # Without 'libgl1', your app will crash when running tools.py
6
  RUN apt-get update && apt-get install -y \
7
- libgl1-mesa-glx \
8
  libglib2.0-0 \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # 2. Set up a user (Hugging Face security requirement)
13
  RUN useradd -m -u 1000 user
 
 
14
  USER user
 
 
15
  ENV HOME=/home/user \
16
  PATH=/home/user/.local/bin:$PATH
17
 
18
- # 3. Set working directory
19
  WORKDIR $HOME/app
20
 
21
- # 4. Copy requirements and install Python libraries
22
  COPY --chown=user requirements.txt requirements.txt
 
 
23
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
24
 
25
- # 5. Copy your application code
26
  COPY --chown=user . .
27
 
28
- # 6. Expose the required port
29
  EXPOSE 7860
30
 
31
- # 7. Run Streamlit
32
- # --server.enableXsrfProtection=false is REQUIRED for file uploads to work in Docker Spaces
33
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
1
+ # Use the official Python 3.10 slim image
2
  FROM python:3.10-slim
3
 
4
+ # 1. Install system dependencies
5
+ # FIXED: Replaced 'libgl1-mesa-glx' (deprecated) with 'libgl1'
6
  RUN apt-get update && apt-get install -y \
7
+ libgl1 \
8
  libglib2.0-0 \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # 2. Set up a new user named "user" with user ID 1000
13
  RUN useradd -m -u 1000 user
14
+
15
+ # Switch to the "user" context
16
  USER user
17
+
18
+ # Set home environment variables
19
  ENV HOME=/home/user \
20
  PATH=/home/user/.local/bin:$PATH
21
 
22
+ # 3. Set the working directory
23
  WORKDIR $HOME/app
24
 
25
+ # 4. Copy requirements file first (Better for caching)
26
  COPY --chown=user requirements.txt requirements.txt
27
+
28
+ # Install Python dependencies
29
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
30
 
31
+ # 5. Copy the rest of your application code
32
  COPY --chown=user . .
33
 
34
+ # 6. Expose the port Hugging Face expects
35
  EXPOSE 7860
36
 
37
+ # 7. Run the Streamlit application
 
38
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]