Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +24 -7
Dockerfile
CHANGED
|
@@ -2,11 +2,12 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Set
|
| 6 |
ENV HOME=/app
|
| 7 |
-
ENV MPLCONFIGDIR=/
|
| 8 |
-
ENV TORCH_HOME=/
|
| 9 |
-
ENV STREAMLIT_HOME=/
|
|
|
|
| 10 |
|
| 11 |
# Install system dependencies
|
| 12 |
RUN apt-get update && apt-get install -y \
|
|
@@ -25,8 +26,9 @@ RUN apt-get update && apt-get install -y \
|
|
| 25 |
zlib1g-dev \
|
| 26 |
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
|
| 28 |
-
# Create
|
| 29 |
-
RUN mkdir -p /
|
|
|
|
| 30 |
|
| 31 |
# Copy project files
|
| 32 |
COPY requirements.txt ./
|
|
@@ -39,8 +41,23 @@ RUN pip install --upgrade pip && \
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Set up environment variables for writable directories
|
| 6 |
ENV HOME=/app
|
| 7 |
+
ENV MPLCONFIGDIR=/tmp/.matplotlib
|
| 8 |
+
ENV TORCH_HOME=/tmp/.torch
|
| 9 |
+
ENV STREAMLIT_HOME=/tmp/.streamlit
|
| 10 |
+
ENV PYTHONPATH=$PYTHONPATH:/app
|
| 11 |
|
| 12 |
# Install system dependencies
|
| 13 |
RUN apt-get update && apt-get install -y \
|
|
|
|
| 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 |
# Copy project files
|
| 34 |
COPY requirements.txt ./
|
|
|
|
| 41 |
pip install torchvision==0.15.2 && \
|
| 42 |
pip install 'git+https://github.com/facebookresearch/detectron2.git'
|
| 43 |
|
| 44 |
+
# Set proper ownership for application files
|
| 45 |
+
RUN chown -R 1000:1000 /app
|
| 46 |
+
|
| 47 |
+
# Expose Streamlit port
|
| 48 |
EXPOSE 8501
|
| 49 |
|
| 50 |
+
# Add a healthcheck
|
| 51 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 52 |
|
| 53 |
+
# Run as non-root user for better security
|
| 54 |
+
USER 1000
|
| 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 |
+
# Command to run the app
|
| 63 |
+
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|