FROM theosotr/sqlite3-test AS base


FROM python:3.14.4-slim-trixie AS build

USER root

RUN apt-get update
RUN apt-get install build-essential tcl -y
RUN rm -rf /var/lib/apt/lists/*

RUN mkdir /home/test

COPY --from=base /home/test/seeds /home/test/seeds
COPY --from=base /usr/bin/sqlite3 /usr/bin/
COPY --from=base /home/test/sqlite3-src /home/test/sqlite3-src

COPY rot13.c /home/test/sqlite3-src/build/

# Instrument SQLite with gcov
RUN cd /home/test/sqlite3-src/build && ../configure CFLAGS="--coverage -g -O0" && make clean && make -j$(nproc)

RUN cd /home/test/sqlite3-src/build && ../configure CFLAGS="--coverage -g -O0" && gcc -g -fPIC -shared rot13.c -o rot13.so

COPY requirements.txt ./

RUN pip install -r requirements.txt
RUN ln -s /usr/bin/python3 /usr/bin/python 2>/dev/null || true

FROM build

WORKDIR /fuzzer

COPY fuzzer.py mutator_extra_statements.py mutator_corpus_splicing.py mutator_equivalent_rewrites.py mutator_operators.py mutator_values.py mutator.py oracle.py runner.py sqlite_static_helper.py stats.py entrypoint.sh additional.sql *.db ./
RUN echo "SELECT 1;" > commands.sql

# Project Spec: "The executable file of your tool must be called /usr/bin/test-db inside the Docker image."
COPY entrypoint.sh /usr/bin/test-db

RUN chmod +x /usr/bin/test-db
ENTRYPOINT ["/usr/bin/test-db"]
