FROM python:3.12-slim-bullseye AS builder

RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc g++ binutils libgmp-dev \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir \
    trio click msgpack multiaddr setuptools wheel \
    coincurve cffi \
    PySide6 \
    pyinstaller

WORKDIR /app

# Install local packages first (better caching)
COPY ipfs-lite/py-ipfs-lite/ /deps/py-ipfs-lite/
COPY py-libp2p/ /deps/py-libp2p/
RUN pip install --no-cache-dir /deps/py-ipfs-lite/ && \
    pip install --no-cache-dir /deps/py-libp2p/

# Copy PeerDrop project
COPY PeerDrop/ /app/peerdrop-project/
WORKDIR /app/peerdrop-project

# Build both CLI and GUI
RUN python packaging/build.py --clean
