vs / Dockerfile
devmm03's picture
.
cd94836
Raw History Blame Contribute Delete
1.29 kB
FROM python:3.12-slim
WORKDIR /app
# Install system dependencies required for audio processing (libsndfile)
RUN apt-get update && apt-get install -y \
libsndfile1 \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user (recommended for security and HF Spaces)
RUN useradd -m -u 1000 user
# Switch to user to install python dependencies?
# Usually better to install as root to system or as user to user --user
# For simplicity and standard HF spaces, we can keep install as root but ensure perms are right.
# Actually, standard pattern often is:
# 1. User setup
# 2. Env setup
# 3. Copy chown
# Copy requirements first to leverage Docker cache
COPY --chown=user requirements.txt .
# Install python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application with correct ownership
COPY --chown=user . .
# Create directories that are not copied but required
# and ensure the entire app directory is owned by user
RUN mkdir -p data temp logs && chown -R user:user /app
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose the port used by Hugging Face Spaces (7860)
EXPOSE 7860
# Start the application on port 7860
CMD ["python", "main.py", "serve", "--host", "0.0.0.0", "--port", "7860"]