Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +28 -47
Dockerfile
CHANGED
|
@@ -2,74 +2,55 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Set
|
| 6 |
-
ENV
|
| 7 |
-
ENV
|
| 8 |
-
ENV
|
| 9 |
-
ENV
|
| 10 |
-
ENV PYTHONPATH=$PYTHONPATH:/app
|
| 11 |
|
| 12 |
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y \
|
| 14 |
build-essential \
|
| 15 |
-
curl \
|
| 16 |
-
software-properties-common \
|
| 17 |
git \
|
| 18 |
libgl1-mesa-glx \
|
| 19 |
libglib2.0-0 \
|
| 20 |
-
libffi-dev \
|
| 21 |
-
libssl-dev \
|
| 22 |
-
libbz2-dev \
|
| 23 |
-
liblzma-dev \
|
| 24 |
-
libreadline-dev \
|
| 25 |
-
libsqlite3-dev \
|
| 26 |
-
zlib1g-dev \
|
| 27 |
wget \
|
| 28 |
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
|
| 30 |
-
# Create
|
| 31 |
RUN mkdir -p /tmp/.torch /tmp/.streamlit /tmp/.matplotlib \
|
| 32 |
&& chmod 777 /tmp/.torch /tmp/.streamlit /tmp/.matplotlib
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
RUN pip install --no-cache-dir
|
| 36 |
|
| 37 |
-
# Install
|
| 38 |
-
RUN pip install --no-cache-dir
|
| 39 |
|
| 40 |
-
# Install
|
| 41 |
-
RUN pip install --no-cache-dir
|
|
|
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
|
| 46 |
-
# Install
|
| 47 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 48 |
-
|
| 49 |
-
# Install detectron2 from GitHub (with specific commit for stability)
|
| 50 |
RUN pip install --no-cache-dir 'git+https://github.com/facebookresearch/detectron2.git@v0.6'
|
| 51 |
|
| 52 |
-
# Create
|
| 53 |
RUN mkdir -p /app/src
|
| 54 |
-
COPY src/ ./src/
|
| 55 |
-
|
| 56 |
-
# Set up Streamlit configuration
|
| 57 |
-
RUN mkdir -p /tmp/.streamlit && echo '\
|
| 58 |
-
[general]\n\
|
| 59 |
-
email = ""\n\
|
| 60 |
-
' > /tmp/.streamlit/credentials.toml
|
| 61 |
|
| 62 |
-
#
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
# Expose Streamlit port
|
| 66 |
-
EXPOSE 8501
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
|
| 73 |
|
| 74 |
-
#
|
| 75 |
-
|
|
|
|
| 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"]
|