Spaces:
Sleeping
Sleeping
Senum2001 commited on
Commit ·
f6c038a
1
Parent(s): eba5a08
Fix Dockerfile: Add --user flag, ca-certificates, and improve gdown with --fuzzy flag
Browse files- Dockerfile +13 -9
Dockerfile
CHANGED
|
@@ -4,14 +4,16 @@ FROM python:3.10-slim
|
|
| 4 |
# Create non-root user
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
-
# Set working directory
|
| 8 |
WORKDIR /app
|
|
|
|
| 9 |
|
| 10 |
# Install system dependencies for OpenCV (minimal)
|
| 11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
libgl1 \
|
| 13 |
libglib2.0-0 \
|
| 14 |
wget \
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/* \
|
| 16 |
&& apt-get clean
|
| 17 |
|
|
@@ -21,14 +23,16 @@ COPY --chown=user:user requirements.txt ./
|
|
| 21 |
# Switch to user before installing Python packages
|
| 22 |
USER user
|
| 23 |
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
|
| 24 |
|
| 25 |
# Install Python dependencies with optimizations
|
| 26 |
-
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 27 |
pip cache purge
|
| 28 |
|
| 29 |
-
# Download model checkpoint from Google Drive
|
| 30 |
-
RUN pip install --no-cache-dir gdown && \
|
| 31 |
-
gdown --id 1ftzxTJUnlxpQFqPlaUozG_JUbl1Qi5tQ -O /app/model_checkpoint.ckpt && \
|
|
|
|
| 32 |
pip uninstall -y gdown && \
|
| 33 |
pip cache purge
|
| 34 |
|
|
@@ -37,10 +41,10 @@ COPY --chown=user:user app.py inference_core.py ./
|
|
| 37 |
COPY --chown=user:user scripts/ ./scripts/
|
| 38 |
COPY --chown=user:user configs/ ./configs/
|
| 39 |
|
| 40 |
-
# Create output directories
|
| 41 |
-
RUN mkdir -p api_inference_pred_masks_pipeline \
|
| 42 |
-
api_inference_filtered_pipeline \
|
| 43 |
-
api_inference_labeled_boxes_pipeline
|
| 44 |
|
| 45 |
# Expose port for Hugging Face Spaces
|
| 46 |
EXPOSE 7860
|
|
|
|
| 4 |
# Create non-root user
|
| 5 |
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
+
# Set working directory and permissions
|
| 8 |
WORKDIR /app
|
| 9 |
+
RUN chown -R user:user /app
|
| 10 |
|
| 11 |
# Install system dependencies for OpenCV (minimal)
|
| 12 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
libgl1 \
|
| 14 |
libglib2.0-0 \
|
| 15 |
wget \
|
| 16 |
+
ca-certificates \
|
| 17 |
&& rm -rf /var/lib/apt/lists/* \
|
| 18 |
&& apt-get clean
|
| 19 |
|
|
|
|
| 23 |
# Switch to user before installing Python packages
|
| 24 |
USER user
|
| 25 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 26 |
+
ENV HOME=/home/user
|
| 27 |
|
| 28 |
# Install Python dependencies with optimizations
|
| 29 |
+
RUN pip install --no-cache-dir --user -r requirements.txt && \
|
| 30 |
pip cache purge
|
| 31 |
|
| 32 |
+
# Download model checkpoint from Google Drive (with retries)
|
| 33 |
+
RUN pip install --no-cache-dir --user gdown && \
|
| 34 |
+
gdown --fuzzy --id 1ftzxTJUnlxpQFqPlaUozG_JUbl1Qi5tQ -O /app/model_checkpoint.ckpt && \
|
| 35 |
+
ls -lh /app/model_checkpoint.ckpt && \
|
| 36 |
pip uninstall -y gdown && \
|
| 37 |
pip cache purge
|
| 38 |
|
|
|
|
| 41 |
COPY --chown=user:user scripts/ ./scripts/
|
| 42 |
COPY --chown=user:user configs/ ./configs/
|
| 43 |
|
| 44 |
+
# Create output directories with proper permissions
|
| 45 |
+
RUN mkdir -p /app/api_inference_pred_masks_pipeline && \
|
| 46 |
+
mkdir -p /app/api_inference_filtered_pipeline && \
|
| 47 |
+
mkdir -p /app/api_inference_labeled_boxes_pipeline
|
| 48 |
|
| 49 |
# Expose port for Hugging Face Spaces
|
| 50 |
EXPOSE 7860
|