Dockerfile 822 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Tolan Backend Dockerfile
  2. FROM python:3.11-slim
  3. # Set working directory
  4. WORKDIR /app
  5. # Install system dependencies
  6. RUN apt-get update && apt-get install -y \
  7. ffmpeg \
  8. libsndfile1 \
  9. && rm -rf /var/lib/apt/lists/*
  10. # Copy requirements first for better caching
  11. COPY requirements.txt .
  12. # Install Python dependencies
  13. RUN pip install --no-cache-dir -r requirements.txt
  14. # Copy source code
  15. COPY src/ src/
  16. COPY run.py .
  17. COPY .env.example .env
  18. # Create non-root user
  19. RUN useradd --create-home --shell /bin/bash tolan
  20. RUN chown -R tolan:tolan /app
  21. USER tolan
  22. # Expose port
  23. EXPOSE 8765
  24. # Health check
  25. HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  26. CMD python -c "import socket; socket.create_connection(('localhost', 8765), timeout=5)"
  27. # Run the application
  28. CMD ["python", "run.py"]