# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory
WORKDIR /app

# Change the owner and permissions of the working directory
RUN chown -R 1000:1000 /app && chmod -R 755 /app

# Copy requirements.txt into the container
COPY requirements.txt .

# Install system dependencies and any needed packages specified in requirements.txt
RUN apt-get update && \
    apt-get install -y --no-install-recommends build-essential && \
    pip install --trusted-host pypi.python.org -r requirements.txt

# Copy the rest of the application code into the container
COPY . .

# Expose the port the app will run on
EXPOSE 7860

# Start the application
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
