Dockerfile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. RUN for scene in title game; do \
  31. timeout 60 godot --headless --path . res://scenes/$scene.tscn --quit-after 1200 2>&1 | tee -a /tmp/run.log; \
  32. done \
  33. && ! grep -E "SCRIPT ERROR|^ERROR" /tmp/run.log
  34. FROM scratch
  35. COPY --from=build /project/build/ /