FROM semgrep/semgrep:latest

USER root

RUN sed -i 's/https/http/g' /etc/apk/repositories && \
    apk update && apk add --no-cache python3 py3-pip git

RUN pip install --no-cache-dir \
    --trusted-host pypi.org \
    --trusted-host files.pythonhosted.org \
    --break-system-packages \
    fastapi uvicorn

WORKDIR /app

# COPY r2c-security-audit.yaml /app/r2c-security-audit.yaml
COPY rules/ /app/rules/
RUN sed -i 's/adjust_for_docker()/pass/g' /usr/lib/python3.12/site-packages/semgrep/commands/scan.py

COPY main.py .

EXPOSE 8004

CMD ["python3", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8004"]