# 1. Start with a stable base image FROM python:3.10.13-slim-bullseye # 2. Install git as the root user RUN apt-get update && apt-get install -y --no-install-recommends git && \ apt-get clean && rm -rf /var/lib/apt/lists/* # 3. Create a non-root user for security RUN useradd --create-home --shell /bin/bash --uid 1000 user # 4. Set the working directory in the new user's home WORKDIR /home/user/app # 5. Copy files and install dependencies COPY ./requirements.txt . COPY ./mine_diffs.py . RUN pip install --no-cache-dir --upgrade -r requirements.txt # 6. Change ownership of the app directory to the non-root user. # This is the critical step to grant write permissions. RUN chown -R user:user /home/user/app # 7. Switch to the non-root user USER user # 8. Run the script automatically on startup CMD ["python", "mine_diffs.py"]