# Dockerfile

# 1. Use an official Python runtime as a parent image
FROM python:3.11-slim

# 2. Set the working directory inside the container
WORKDIR /app

# 3. Copy the dependency file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 4. Copy the application code into the container
# Copy the application and test code
COPY app/ ./app/
COPY tests/ ./tests/

# Generate gRPC stubs
RUN python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. app/protos/agent.proto
RUN python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. app/protos/browser.proto

# 5. Expose the port the app runs on
EXPOSE 8000
EXPOSE 50051

# 6. Define the command to run the application
#    --host 0.0.0.0 makes the server accessible from outside the container
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers", "--forwarded-allow-ips", "*"]