Dockerfile 1014 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Use a Python base image (slim version to keep it small)
  2. FROM python:3.9-slim-buster
  3. # Install git
  4. RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
  5. # Set the working directory inside the container
  6. WORKDIR /app
  7. # Set the home directory environment variable
  8. ENV HOME=/home/appuser
  9. # Create a non-root user and group
  10. RUN groupadd -r appgroup && useradd --no-log-init -r -g appgroup -d /home/appuser -m appuser
  11. # Install any necessary dependencies (in this case, just the google-generativeai library)
  12. RUN pip install --no-cache-dir google-generativeai
  13. # Copy the Python script into the container
  14. COPY git_commit_ai.py /app/
  15. # Make the script executable
  16. RUN chmod +x /app/git_commit_ai.py
  17. WORKDIR /repo
  18. # Change ownership of the app and repo directories
  19. RUN chown -R appuser:appgroup /app && chown -R appuser:appgroup /repo
  20. # Switch to the non-root user
  21. USER appuser
  22. # Set the entrypoint to run the script when the container starts
  23. ENTRYPOINT ["python", "/app/git_commit_ai.py"]