# GODOT_VERSION selects the barichello/godot-ci base tag (Godot 4.0+ only — see
# docs/handoff/godot-ci-custom-image.md). BLENDER_URL is the tarball to bake in;
# .gitea/workflows/publish.yml always resolves both at build time via
# scripts/resolve-godot-version.sh and scripts/resolve-blender-url.sh. The
# defaults below are only a fallback for a plain local `docker build`.
ARG GODOT_VERSION=4.7.1
FROM barichello/godot-ci:${GODOT_VERSION}

ARG BLENDER_URL=https://download.blender.org/release/Blender4.2/blender-4.2.3-linux-x64.tar.xz

RUN apt-get update && apt-get install -y --no-install-recommends \
    libfontconfig1 \
    build-essential scons pkg-config xz-utils curl \
    libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev \
    libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev libwayland-dev \
    mingw-w64 \
    # Blender's own runtime deps, not pulled in by anything above — without
    # these `blender --version` fails with "libxkbcommon.so.0: cannot open
    # shared object file" (caught via a local `docker build`, see README).
    libxkbcommon0 libsm6 libice6 \
  && update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \
  && update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix \
  && rm -rf /var/lib/apt/lists/* \
  # Blender is not bundled in barichello/godot-ci, and Ubuntu's apt package lags
  # (stuck on 4.0.2 on noble) — install the resolved tarball straight from
  # download.blender.org instead of `apt-get install blender`.
  && curl -fsSL "$BLENDER_URL" -o /tmp/blender.tar.xz \
  && mkdir -p /opt/blender \
  && tar -xJf /tmp/blender.tar.xz -C /opt/blender --strip-components=1 \
  && ln -sf /opt/blender/blender /usr/local/bin/blender \
  && rm /tmp/blender.tar.xz
