FROM pspdev/pspdev:latest
WORKDIR /workdir
RUN apk add --no-cache \
  python3 \
  py3-pip \
  py3-dotenv \
  git \
  cmake \
  make \
  g++ \
  sdl2-dev \
  zlib-dev \
  linux-headers

# PPSSPP has no Alpine/Linux distro package -- build the "PPSSPPHeadless"
# target (the CLI/no-window build PPSSPP's own CI uses for automated runs)
# from source instead. The target name and exact CMake options have moved
# around across PPSSPP versions -- if this breaks, check
# https://github.com/hrydgard/ppsspp's CMakeLists.txt for the current name.
RUN git clone --recursive --depth 1 \
    https://github.com/hrydgard/ppsspp.git /opt/ppsspp && \
  cd /opt/ppsspp && \
  cmake -B build -DCMAKE_BUILD_TYPE=Release && \
  cmake --build build --target PPSSPPHeadless -- -j$(nproc) && \
  cp build/PPSSPPHeadless /usr/local/bin/PPSSPPHeadless && \
  rm -rf /opt/ppsspp

VOLUME ["/workdir"]
