sandbox338 commited on
Commit
22574ff
·
verified ·
1 Parent(s): e92a879

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -38
Dockerfile CHANGED
@@ -2,55 +2,45 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
- # Set environment variables
6
- ENV PYTHONUNBUFFERED=1
7
- ENV PYTHONDONTWRITEBYTECODE=1
8
- ENV STREAMLIT_SERVER_PORT=7860
9
- ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
10
 
11
  # Install system dependencies
12
  RUN apt-get update && apt-get install -y \
13
  build-essential \
 
 
14
  git \
15
  libgl1-mesa-glx \
16
  libglib2.0-0 \
17
- wget \
 
 
 
 
 
 
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
- # Create writable directories in /tmp
21
- RUN mkdir -p /tmp/.torch /tmp/.streamlit /tmp/.matplotlib \
22
- && chmod 777 /tmp/.torch /tmp/.streamlit /tmp/.matplotlib
23
 
24
- # Install PyTorch first (specify CPU version)
25
- RUN pip install --no-cache-dir torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
26
-
27
- # Install numpy specifically to avoid version conflicts
28
- RUN pip install --no-cache-dir "numpy>=1.21.0,<1.27.0"
29
-
30
- # Install detection dependencies - separate critical ones
31
- RUN pip install --no-cache-dir cython wheel fvcore iopath
32
- RUN pip install --no-cache-dir pycocotools matplotlib pyyaml tqdm
33
-
34
- # Install Streamlit and OpenCV
35
- RUN pip install --no-cache-dir streamlit>=1.20.0,<1.46.0 opencv-python-headless>=4.5.0,<4.12.0 pillow>=9.0.0,<12.0.0
36
-
37
- # Install detectron2 directly, without going through requirements.txt
38
- RUN pip install --no-cache-dir 'git+https://github.com/facebookresearch/detectron2.git@v0.6'
39
-
40
- # Create app structure
41
- RUN mkdir -p /app/src
42
-
43
- # Copy app files
44
  COPY src/ ./src/
45
 
46
- # Configure Streamlit
47
- RUN mkdir -p /tmp/.streamlit && \
48
- echo '[server]\nheadless = true\nenableCORS = false\nenableXsrfProtection = false' > /tmp/.streamlit/config.toml && \
49
- echo '[general]\nemail = ""' > /tmp/.streamlit/credentials.toml && \
50
- chmod -R 777 /tmp/.streamlit
 
 
 
51
 
52
- # Expose the port Streamlit will run on
53
- EXPOSE 7860
54
 
55
- # Run the app
56
- CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
2
 
3
  WORKDIR /app
4
 
5
+ # Set HOME to a writable location
6
+ ENV HOME=/app
7
+ ENV MPLCONFIGDIR=/app/.config/matplotlib
8
+ ENV TORCH_HOME=/app/.torch
9
+ ENV STREAMLIT_HOME=/app/.streamlit
10
 
11
  # Install system dependencies
12
  RUN apt-get update && apt-get install -y \
13
  build-essential \
14
+ curl \
15
+ software-properties-common \
16
  git \
17
  libgl1-mesa-glx \
18
  libglib2.0-0 \
19
+ libffi-dev \
20
+ libssl-dev \
21
+ libbz2-dev \
22
+ liblzma-dev \
23
+ libreadline-dev \
24
+ libsqlite3-dev \
25
+ zlib1g-dev \
26
  && rm -rf /var/lib/apt/lists/*
27
 
28
+ # Create required writable folders
29
+ RUN mkdir -p /app/.torch /app/.streamlit /app/.config/matplotlib
 
30
 
31
+ # Copy project files
32
+ COPY requirements.txt ./
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  COPY src/ ./src/
34
 
35
+ # Install Python dependencies
36
+ RUN pip install --upgrade pip && \
37
+ pip install "numpy<2.0" && \
38
+ pip install -r requirements.txt && \
39
+ pip install torchvision==0.15.2 && \
40
+ pip install 'git+https://github.com/facebookresearch/detectron2.git'
41
+
42
+ EXPOSE 8501
43
 
44
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
 
45
 
46
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]