Spaces:
Sleeping
Sleeping
FROM python:3.9-slim | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
ENV PORT=8080 | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
# Switch to root for system installations | |
USER root | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
libsndfile1 \ | |
ffmpeg \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Switch back to non-root user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
WORKDIR /app | |
# Copy requirements and install Python dependencies | |
COPY --chown=user:users requirements.txt /app/requirements.txt | |
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of the project files | |
COPY --chown=user:users . /app | |
# Ensure outputs and temp directories exist | |
RUN mkdir -p outputs temp | |
# Expose port 8080 | |
EXPOSE 8080 | |
# Run the application | |
CMD ["python", "app.py"] | |