# Use Python 3.10 slim image FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PYTHONPATH="/app" # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ netcat-openbsd \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Create app user first (before creating directories) RUN useradd -m -u 1000 app # Create necessary directories and set permissions RUN mkdir -p /app/storage/audio \ /app/storage/text \ /app/storage/temp \ && chown -R app:app /app # Copy requirements first to leverage Docker cache COPY --chown=app:app requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the entire application code COPY --chown=app:app . . # Make scripts executable RUN chmod +x /app/scripts/*.sh # Switch to app user USER app # Expose port EXPOSE 7860 # Set entrypoint ENTRYPOINT ["/app/scripts/run.sh"]