Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +14 -25
Dockerfile
CHANGED
|
@@ -1,38 +1,27 @@
|
|
| 1 |
# 1. Base Image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
# 2. Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 6 |
ENV PYTHONUNBUFFERED 1
|
| 7 |
-
ENV STREAMLIT_SERVER_HEADLESS=true
|
| 8 |
-
# --- THE DEFINITIVE FIX IS HERE ---
|
| 9 |
-
# Tell Hugging Face to use a cache directory INSIDE the user's home folder
|
| 10 |
-
ENV HF_HOME=/home/user/.cache/huggingface
|
| 11 |
-
# --- END FIX ---
|
| 12 |
|
| 13 |
-
# 3. Install
|
| 14 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
-
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
-
# 4.
|
| 19 |
-
|
| 20 |
-
USER user
|
| 21 |
-
WORKDIR /home/user/app
|
| 22 |
|
| 23 |
-
# 5. Copy
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
# 6. Pre-download the model's configuration files (as the correct user)
|
| 28 |
-
# This is a small download and ensures the cache directory is created.
|
| 29 |
-
RUN python -c "from transformers import AutoImageProcessor; AutoImageProcessor.from_pretrained('google/efficientnet-b2')"
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
RUN git lfs pull
|
| 34 |
|
| 35 |
-
#
|
| 36 |
EXPOSE 8501
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
| 1 |
# 1. Base Image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# 2. Set environment variables for a non-interactive server
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE 1
|
| 6 |
ENV PYTHONUNBUFFERED 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# 3. Install the single critical system dependency for OpenCV
|
| 9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
+
libgl1 \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# 4. Set the working directory
|
| 14 |
+
WORKDIR /app
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# 5. Copy ALL necessary files at once (respecting .dockerignore)
|
| 17 |
+
# This is the simplest and most robust way.
|
| 18 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# 6. Install Python packages and immediately clean up the cache
|
| 21 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 22 |
|
| 23 |
+
# 7. Expose the port
|
| 24 |
EXPOSE 8501
|
| 25 |
+
|
| 26 |
+
# 8. Entrypoint to run the app
|
| 27 |
+
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableCORS", "false"]
|