build(web): two-step import+export, diagnose templates, drop --path

- Split into godot --import then godot --export-release to avoid the
  race condition where _fs_changed fires before Web export platform
  is fully registered (causes empty "configuration errors" list)
- Remove --path /project (WORKDIR is already /project; matches
  barichello/godot-ci example usage)
- Add diagnostic RUN that prints the export_templates directory so
  CI logs reveal missing templates immediately
- Expand fallback export_presets.cfg with all required Godot 4.5
  Web preset fields (custom_template, variant/extensions_support)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-28 08:09:14 -05:00
co-authored by Claude Happy
parent 9cc4dc7ad3
commit c6177cd627
+28 -4
View File
@@ -6,16 +6,29 @@ COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends fontconfig && rm -rf /var/lib/apt/lists/*
# Web export in Godot 4 requires Compatibility renderer; project defaults may differ.
# Harden CI: ensure export preset exists and editor cache paths are writable.
# Safety-net sed: replace any renderer value with gl_compatibility (project.godot already
# uses gl_compatibility; this guards against accidental revert).
RUN sed -i 's#renderer/rendering_method="[^"]*"#renderer/rendering_method="gl_compatibility"#g' project.godot
# Harden CI: ensure export preset exists.
RUN test -f export_presets.cfg || cat > export_presets.cfg <<'CFG'
[preset.0]
name="HTML5"
platform="Web"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/web/index.html"
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=true
html/export_icon=true
@@ -26,9 +39,20 @@ html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
CFG
RUN sed -i 's#renderer/rendering_method="[^"]*"#renderer/rendering_method="gl_compatibility"#g' project.godot \
&& mkdir -p .godot/editor build/web \
&& godot --headless --path /project --export-release "HTML5" build/web/index.html
# Diagnostic: confirm web export templates are present.
RUN echo "=== Godot export templates ===" \
&& find /root/.local/share/godot/export_templates -maxdepth 2 -type f 2>/dev/null | sort \
|| echo "WARNING: no export templates found at default path"
# Step 1 — import all project resources so the editor cache is fully populated
# before the export step. Running --import first avoids the race condition where
# _fs_changed triggers the export before all editor plugins have registered.
RUN mkdir -p .godot/editor .godot/imported build/web \
&& godot --headless --import 2>&1 | tail -10 || true
# Step 2 — export. Drop --path so Godot uses WORKDIR (matches barichello examples).
RUN godot --headless --export-release "HTML5" build/web/index.html
FROM nginx:1.27-alpine
COPY --from=build /project/build/web/ /usr/share/nginx/html/