| # Use Python 3.10 as the base image | |
| FROM python:3.10-slim | |
| # Set the working directory in the container | |
| WORKDIR /app/src | |
| # Debug: Print the current working directory and list the files | |
| RUN echo "Debugging the source directory during build context:" && pwd && ls -R / | |
| # Copy requirements.txt from the source directory to /app/src | |
| COPY ./src/requirements.txt /app/src/requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r /app/src/requirements.txt | |
| # Copy the source code to the container | |
| COPY . . | |
| # Expose ports for FastAPI and Streamlit apps | |
| EXPOSE 8000 8501 | |
| # Create a script to run both FastAPI and Streamlit apps | |
| RUN echo '#!/bin/bash\n\ | |
| python response_api.py &\n\ | |
| sleep 5\n\ | |
| streamlit run app.py' > ./start.sh | |
| # Make the script executable | |
| RUN chmod +x ./start.sh | |
| # Run the startup script | |
| CMD ["./start.sh"] | |