# Use python 3.10 as base image.
FROM python:3.10-bullseye

# Add local user and grant access to app and venv directories.
RUN useradd -ms /bin/bash appuser \
  && mkdir -p /home/appuser/.ssh \
  && chown -R appuser:appuser /home/appuser/.ssh \
  && mkdir -p /app/.virtualenv \
  && chown -R appuser:appuser /app

# Configure environment.
USER appuser
WORKDIR /app
ENV PATH="/app/.virtualenv/bin:${PATH}"

# Create virtualenv.
RUN python -m venv /app/.virtualenv

# Install dependencies.
COPY --chown=appuser:appuser requirements.txt ./
RUN pip install --upgrade pip \
  && pip install -r ./requirements.txt

# Deploy application.
COPY --chown=appuser:appuser . ./

# Configure environment variables.
ENV GITHUB_API_KEY="" \
  GITHUB_REPO_NAME="" \
  GITHUB_PR_NUM=""

CMD ["python", "/app/cleanup/main.py"]
