CoolFace
Apppublic

Sahilrathore26/depth-estimation

sourceHugging Faceotherupdated 1y agoView on Hugging Face
0likes
Dockerfile46 linesDownload Raw Back to root
1# 1. Base Image2FROM python:3.10-slim3 4# 2. Set Working Directory5WORKDIR /app6 7# 3. Copy Requirements File8COPY requirements.txt .9 10# 4. Install Dependencies11RUN pip install --no-cache-dir --upgrade pip -r requirements.txt12 13# 5. Copy Application Code14COPY ./app.py .15COPY ./index.html .16# COPY ./background.jpg . # <-- Uncomment if needed17 18# --- Environment Variables & Writable Dirs ---19# Define cache directories within /tmp20ENV TORCH_HOME=/tmp/torch_cache21ENV HF_HOME=/tmp/hf_cache22ENV MPLCONFIGDIR=/tmp/matplotlib_cache23 24# Create the directories AND set MORE PERMISSIVE permissions25# Create directories and make them world-writable (777)26# This is less secure but often works around permission issues in /tmp27RUN mkdir -p /tmp/torch_cache /tmp/hf_cache /tmp/matplotlib_cache && \28    chmod -R 777 /tmp/torch_cache /tmp/hf_cache /tmp/matplotlib_cache29# Still create a non-root user for running the app itself30RUN groupadd -r appgroup && useradd --no-log-init -r -g appgroup appuser && \31    chown -R appuser:appgroup /app # Own the app code directory32# --- End Environment Variables & Dirs ---33 34# 6. Expose Port35EXPOSE 786036 37# --- Switch to the non-root user ---38# The app will run as appuser, but the /tmp dirs are world-writable39USER appuser40 41# 7. Set Healthcheck (Optional but Recommended)42HEALTHCHECK --interval=15s --timeout=3s --start-period=5s \43  CMD curl --fail http://localhost:7860/ || exit 144 45# 8. Run Command46CMD ["gunicorn", "-w", "1", "-k", "uvicorn.workers.UvicornWorker", "app:app", "--bind", "0.0.0.0:7860", "--timeout", "120"]