# Step 1: Use Python 3.10.6 as the base image FROM python:3.10.6 # Step 2: Set the working directory inside the container WORKDIR /app # Step 3: Copy the requirements.txt file to the working directory COPY requirements.txt . # Step 4: Install the Python dependencies from the requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Step 5: Create a directory for data storage (e.g., for downloaded videos or extracted audio) # Ensure that this directory has the right permissions for writing. RUN mkdir -p /app/downloaded_videos /app/extracted_audio \ && chmod -R 755 /app/downloaded_videos /app/extracted_audio # Step 6: Create a non-root user for security and switch to that user RUN useradd -m myuser \ && chown -R myuser:myuser /app # Step 7: Copy the rest of the application code to the working directory COPY . . # Step 8: Change ownership of the app directory and files RUN chown -R myuser:myuser /app # Step 9: Switch to the non-root user USER myuser # Step 10: Expose the port that FastAPI runs on EXPOSE 7860 # Step 11: Command to run FastAPI using Uvicorn when the container starts CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]