| # Step 1: Use an official Python image as a base | |
| FROM python:3.11-slim | |
| # Step 2: Set the working directory in the container | |
| WORKDIR /app | |
| # Step 3: Copy the requirements.txt file to the working directory | |
| COPY requirements.txt /app/ | |
| # Step 4: Install dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Step 5: Copy the rest of the application code | |
| COPY . /app/ | |
| # Step 6: Expose the port the app will run on | |
| EXPOSE 7860 | |
| # Step 7: Set environment variable (if you need .env file handling) | |
| # You can optionally copy the .env file if you're using it for environment variables | |
| # COPY .env /app/ | |
| # Step 8: Run the application using uvicorn (FastAPI) | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |