FROM theosotr/sqlite3-reducer

USER root

RUN apt-get update \
  && apt-get install -y --no-install-recommends \
  python3 python3-pip bash ca-certificates \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /reducer

COPY requirements.txt reducer.py entrypoint.sh reduce_all.sh .
RUN pip3 install --no-cache-dir --break-system-packages -r requirements.txt \
  || pip3 install --no-cache-dir -r requirements.txt

RUN ln -s /usr/bin/python3 /usr/bin/python 2>/dev/null || true

COPY entrypoint.sh /usr/bin/reducer
RUN chmod +x /usr/bin/reducer reducer.py entrypoint.sh reduce_all.sh

RUN mkdir -p /reducer/queries

ENTRYPOINT ["/usr/bin/bash"]
