| # Use an official Python runtime as a parent image | |
| FROM python:3.11-slim | |
| # Create a user and set permissions | |
| RUN useradd -m -u 1000 user | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install system dependencies | |
| USER root | |
| RUN apt-get update && apt-get install -y \ | |
| python3-dev \ | |
| libpq-dev \ | |
| gcc \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Ensure .files directory exists and is writable | |
| RUN mkdir -p /app/.files && chown -R user:user /app/.files | |
| # Switch back to the non-root user | |
| USER user | |
| # Copy the rest of the application code into the container | |
| COPY --chown=user . . | |
| # Install any needed packages specified in requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Expose port 8080 to the world outside this container | |
| EXPOSE 7860 | |
| # Run chainlit when the container launches | |
| CMD ["python", "-m", "chainlit", "run", "chatxbt-assistant.py", "-h", "--port", "7860"] | |