| # Use the official Python 3.10.9 image | |
| FROM python:3.10.9 | |
| # Expose the port FastAPI will run on | |
| EXPOSE 7860 | |
| # Set environment variables for FastAPI and OpenAI API keys | |
| ARG FASTAPI_KEY | |
| ARG OPENAI_API_KEY | |
| ENV FASTAPI_KEY=$FASTAPI_KEY | |
| ENV OPENAI_API_KEY=$OPENAI_API_KEY | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set the working directory | |
| WORKDIR /code | |
| # Copy requirements and install dependencies | |
| COPY ./app/requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy the app directory | |
| COPY ./app /code/app | |
| # Start the FastAPI app on port 7860 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |