Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Builds RedCore for Linux with headless Godot, after a smoke test that runs both scenes
  2. # headless and fails on script errors. Copy the binary into ./build with:
  3. # docker build --target test -t redcore-build .
  4. # id=$(docker create redcore-build) && docker cp $id:/project/build/RedCore.x86_64 build/ && docker rm $id
  5. # With BuildKit, `docker build --output build .` does the same in one step.
  6. FROM debian:bookworm-slim AS godot
  7. ARG GODOT_VERSION=4.7.2
  8. ARG GODOT_URL=https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable
  9. RUN apt-get update \
  10. && apt-get install -y --no-install-recommends ca-certificates wget unzip libfontconfig1 \
  11. && rm -rf /var/lib/apt/lists/*
  12. WORKDIR /tmp/godot
  13. RUN wget -q ${GODOT_URL}/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip \
  14. && unzip -q Godot_*.zip \
  15. && mv Godot_v${GODOT_VERSION}-stable_linux.x86_64 /usr/local/bin/godot \
  16. && rm -rf /tmp/godot/*
  17. # Only the Linux export templates are kept from the archive.
  18. RUN wget -q ${GODOT_URL}/Godot_v${GODOT_VERSION}-stable_export_templates.tpz \
  19. && unzip -q Godot_*.tpz 'templates/linux_*' 'templates/version.txt' \
  20. && mkdir -p /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable \
  21. && mv templates/* /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable/ \
  22. && rm -rf /tmp/godot/*
  23. FROM godot AS build
  24. WORKDIR /project
  25. COPY . .
  26. RUN godot --headless --import \
  27. && mkdir -p build \
  28. && godot --headless --export-release "Linux" build/RedCore.x86_64
  29. FROM build AS test
  30. # Quitting while a sound plays makes Godot report that sound as "still in use at exit";
  31. # that one shutdown message is ignored, every other error fails the build.
  32. RUN for scene in title game; do \
  33. timeout 60 godot --headless --path . res://scenes/$scene.tscn --quit-after 1200 2>&1 | tee -a /tmp/run.log; \
  34. done \
  35. && ! grep -E "SCRIPT ERROR|^ERROR" /tmp/run.log | grep -v "resources still in use at exit"
  36. FROM scratch
  37. COPY --from=build /project/build/ /