FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:debian13-python313 AS base

USER root

# Run updates and install Node.js for datadog-ci
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y install -y nodejs npm \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/* \
  && npm install -g @datadog/datadog-ci

# Install poetry for requirements export (if needed)
RUN pip install --upgrade pip \
  && pip install poetry \
  && poetry self add poetry-plugin-export

ADD --chown=worker:worker guarddog_scanner.py rules.py sarif_rules.py requirements.txt /app/

WORKDIR /app

# Install dependencies with pip
RUN pip install -r requirements.txt \
    && rm requirements.txt

# Default command runs the scanner
ENV PYTHONUNBUFFERED=1
ENTRYPOINT ["python", "-u", "/app/guarddog_scanner.py"]
