Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +33 -11
Dockerfile
CHANGED
|
@@ -24,30 +24,52 @@ RUN apt-get update && apt-get install -y \
|
|
| 24 |
libreadline-dev \
|
| 25 |
libsqlite3-dev \
|
| 26 |
zlib1g-dev \
|
|
|
|
| 27 |
&& rm -rf /var/lib/apt/lists/*
|
| 28 |
|
| 29 |
# Create temporary directories with proper permissions
|
| 30 |
RUN mkdir -p /tmp/.torch /tmp/.streamlit /tmp/.matplotlib \
|
| 31 |
&& chmod 777 /tmp/.torch /tmp/.streamlit /tmp/.matplotlib
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
COPY src/ ./src/
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
#
|
|
|
|
|
|
|
|
|
|
| 39 |
COPY requirements.txt ./
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
COPY src/ ./src/
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
RUN
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
pip install 'git+https://github.com/facebookresearch/detectron2.git'
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
EXPOSE 8501
|
| 50 |
|
|
|
|
| 51 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
libreadline-dev \
|
| 25 |
libsqlite3-dev \
|
| 26 |
zlib1g-dev \
|
| 27 |
+
wget \
|
| 28 |
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
|
| 30 |
# Create temporary directories with proper permissions
|
| 31 |
RUN mkdir -p /tmp/.torch /tmp/.streamlit /tmp/.matplotlib \
|
| 32 |
&& chmod 777 /tmp/.torch /tmp/.streamlit /tmp/.matplotlib
|
| 33 |
|
| 34 |
+
# Upgrade pip and install base packages
|
| 35 |
+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
|
|
|
| 36 |
|
| 37 |
+
# Install PyTorch and torchvision first (often the most difficult dependencies)
|
| 38 |
+
RUN pip install --no-cache-dir torch==1.13.1 torchvision==0.14.1 -f https://download.pytorch.org/whl/cpu/torch_stable.html
|
| 39 |
|
| 40 |
+
# Install numpy with version constraint
|
| 41 |
+
RUN pip install --no-cache-dir "numpy<2.0"
|
| 42 |
+
|
| 43 |
+
# Copy only requirements first for better caching
|
| 44 |
COPY requirements.txt ./
|
| 45 |
+
|
| 46 |
+
# Install Python dependencies in smaller batches for better error visibility
|
| 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 the src directory and copy application files
|
| 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 |
+
# Set proper ownership for application files
|
| 63 |
+
RUN chown -R 1000:1000 /app
|
| 64 |
+
|
| 65 |
+
# Expose Streamlit port
|
| 66 |
EXPOSE 8501
|
| 67 |
|
| 68 |
+
# Add a healthcheck
|
| 69 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 70 |
|
| 71 |
+
# Run as non-root user for better security
|
| 72 |
+
USER 1000
|
| 73 |
+
|
| 74 |
+
# Command to run the app
|
| 75 |
+
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|