FROM arm64v8/debian:bullseye

# Add ARM 32Bit
RUN dpkg --add-architecture armhf

# Install Dependencies
RUN \
    apt-get update && \
    apt-get dist-upgrade -y && \
    apt-get install -y libglvnd-dev:armhf libsdl1.2-dev:armhf libx11-dev:armhf build-essential zlib1g-dev:armhf git cmake curl gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libfreeimage-dev:armhf libglfw3-dev:armhf xinput:armhf libxfixes-dev:armhf

# Setup GLES Location
RUN ln -s /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 /usr/lib/libGLESv2.so

# Add Build Scripts
ADD ./build /app/build

WORKDIR /app

# Download MCPI
RUN ./build/download-minecraft-pi.sh

# Build LibPNG12
RUN ./build/build-libpng12.sh

# Add Code
ADD . /app

# Build Mods
RUN ./build/build-mods.sh

WORKDIR ./minecraft-pi

ENTRYPOINT ./launcher