Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +20 -10
Dockerfile
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install necessary dependencies for OpenCV and other utilities
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
| 8 |
curl \
|
|
@@ -12,19 +14,27 @@ RUN apt-get update && apt-get install -y \
|
|
| 12 |
libglib2.0-0 \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Copy the requirements and install them
|
| 22 |
-
COPY requirements.txt ./
|
| 23 |
-
RUN pip3 install -r requirements.txt
|
| 24 |
|
| 25 |
# Copy the source code and modules directory
|
| 26 |
-
COPY src/ ./src/
|
| 27 |
-
COPY modules/ ./modules/
|
| 28 |
|
| 29 |
# Expose the port that Streamlit will run on
|
| 30 |
EXPOSE 8501
|
|
@@ -33,4 +43,4 @@ EXPOSE 8501
|
|
| 33 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 34 |
|
| 35 |
# Set the entry point to run the Streamlit app
|
| 36 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
+
# Use Python 3.9 slim as the base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install necessary dependencies for OpenCV, PyTorch, and other utilities
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
curl \
|
|
|
|
| 14 |
libglib2.0-0 \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# Create a non-root user to avoid permission issues
|
| 18 |
+
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 19 |
+
USER appuser
|
| 20 |
|
| 21 |
+
# Set environment variables for Streamlit and Hugging Face
|
| 22 |
+
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
|
| 23 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
|
| 24 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 25 |
+
ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE=none
|
| 26 |
+
|
| 27 |
+
# Create necessary directories with correct permissions
|
| 28 |
+
RUN mkdir -p /app/.streamlit /app/.cache/huggingface
|
| 29 |
+
RUN chmod -R 777 /app/.streamlit /app/.cache
|
| 30 |
|
| 31 |
# Copy the requirements and install them
|
| 32 |
+
COPY --chown=appuser:appuser requirements.txt ./
|
| 33 |
+
RUN pip3 install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
# Copy the source code and modules directory
|
| 36 |
+
COPY --chown=appuser:appuser src/ ./src/
|
| 37 |
+
COPY --chown=appuser:appuser modules/ ./modules/
|
| 38 |
|
| 39 |
# Expose the port that Streamlit will run on
|
| 40 |
EXPOSE 8501
|
|
|
|
| 43 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 44 |
|
| 45 |
# Set the entry point to run the Streamlit app
|
| 46 |
+
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|