Update Dockerfile
Browse files- Dockerfile +38 -35
Dockerfile
CHANGED
|
@@ -1,48 +1,51 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
-
ENV PYTHONUNBUFFERED=1
|
| 7 |
-
ENV SHELL=/bin/bash
|
| 8 |
-
|
| 9 |
-
# Set working directory
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
-
# Install system dependencies
|
| 13 |
-
#
|
| 14 |
-
#
|
| 15 |
-
#
|
|
|
|
|
|
|
| 16 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 17 |
build-essential \
|
| 18 |
curl \
|
| 19 |
-
software-properties-common \
|
| 20 |
git \
|
|
|
|
| 21 |
ffmpeg \
|
| 22 |
python3-dev \
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
rm -rf /var/lib/apt/lists/*
|
| 26 |
|
| 27 |
-
# Copy requirements file
|
| 28 |
COPY requirements.txt ./
|
| 29 |
|
| 30 |
-
# Install
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set the working directory in the container
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies:
|
| 8 |
+
# - build-essential: For compiling some Python packages if needed
|
| 9 |
+
# - curl, git, software-properties-common: General utilities, git for some pip installs
|
| 10 |
+
# - ffmpeg: For video processing
|
| 11 |
+
# - python3-dev: For C extensions if any Python package needs to build them
|
| 12 |
+
# - libsndfile1: For soundfile to work correctly
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
build-essential \
|
| 15 |
curl \
|
|
|
|
| 16 |
git \
|
| 17 |
+
software-properties-common \
|
| 18 |
ffmpeg \
|
| 19 |
python3-dev \
|
| 20 |
+
libsndfile1 \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
| 22 |
|
| 23 |
+
# Copy the requirements file into the container at /app
|
| 24 |
COPY requirements.txt ./
|
| 25 |
|
| 26 |
+
# Install any needed packages specified in requirements.txt
|
| 27 |
+
# --no-cache-dir: Reduces image size by not storing the pip cache
|
| 28 |
+
# It's good practice to upgrade pip first
|
| 29 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 30 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 31 |
+
|
| 32 |
+
# Copy the rest of the application code into the container at /app
|
| 33 |
+
COPY . .
|
| 34 |
+
|
| 35 |
+
# Make port 7860 available to the world outside this container (Streamlit default)
|
| 36 |
+
# Hugging Face Spaces will handle the actual port mapping.
|
| 37 |
+
EXPOSE 7860
|
| 38 |
+
|
| 39 |
+
# Define environment variables for Hugging Face Hub caching (optional but good practice)
|
| 40 |
+
# These will be overridden by HF Spaces secrets/vars if set there, but good defaults.
|
| 41 |
+
ENV HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface/hub
|
| 42 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 43 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/hub
|
| 44 |
+
ENV DIFFUSERS_CACHE=/app/.cache/huggingface/hub
|
| 45 |
+
# Create the cache directory and set permissions (if needed, usually pip creates it)
|
| 46 |
+
# RUN mkdir -p /app/.cache/huggingface/hub && chmod -R 777 /app/.cache
|
| 47 |
+
|
| 48 |
+
# Command to run the Streamlit application
|
| 49 |
+
# The --server.port and --server.address are important for HF Spaces.
|
| 50 |
+
# --server.fileWatcherType none can prevent issues in some environments.
|
| 51 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.fileWatcherType=none"]
|