FROM barichello/godot-ci:4.5 AS build WORKDIR /project COPY . . # Godot web export depends on fontconfig in this runner image. 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. # 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 html/custom_html_shell="" html/head_include="" html/canvas_resize_policy=2 html/focus_canvas_on_start=true html/experimental_virtual_keyboard=true progressive_web_app/enabled=false CFG # 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/ COPY nginx.default.conf /etc/nginx/conf.d/default.conf EXPOSE 80