# syntax=docker/dockerfile:1
# Reproducible build of tr4mpass with every dependency inside the image, so
# nothing is installed on the host. Debian trixie matches the development host.
FROM debian:trixie-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential pkg-config \
        libimobiledevice-dev libirecovery-1.0-dev libusb-1.0-0-dev libplist-dev \
        libssl-dev libcurl4-openssl-dev libssh2-1-dev \
        usbutils usbmuxd ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /build

# Only what make needs: the Makefile, src/, include/ and tests/ (the
# .chip-db-canary target depends on tests/chip_db_canary.c).
COPY Makefile ./
COPY src ./src
COPY include ./include
COPY tests ./tests

RUN make clean && make

# The binary ends up at /build/tr4mpass.
# Running it needs direct USB access:
#   podman run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb tr4mpass ./tr4mpass -v
CMD ["/bin/bash"]
