perf: accelerate web startup and French pack extraction
This commit is contained in:
+11
-4
@@ -5,6 +5,7 @@ ARG GODOT_VERSION=4.6.3
|
|||||||
FROM ubuntu:24.04 AS web-builder
|
FROM ubuntu:24.04 AS web-builder
|
||||||
ARG GODOT_VERSION
|
ARG GODOT_VERSION
|
||||||
ARG SQLITE_VERSION=4.8
|
ARG SQLITE_VERSION=4.8
|
||||||
|
ARG WEB_BUILD_ID=3.0.1-fr-joy-fast
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
@@ -43,11 +44,11 @@ RUN mkdir -p dist \
|
|||||||
&& find .godot/imported -name 'kalulu_sprite_sheet.png-*.ctex' ! -name '*.etc2.ctex' ! -name '*.s3tc.ctex' -type f -size +0c | grep -q .
|
&& find .godot/imported -name 'kalulu_sprite_sheet.png-*.ctex' ! -name '*.etc2.ctex' ! -name '*.s3tc.ctex' -type f -size +0c | grep -q .
|
||||||
|
|
||||||
RUN godot --headless --path /src --export-release "Web Test" dist/index.html \
|
RUN godot --headless --path /src --export-release "Web Test" dist/index.html \
|
||||||
&& mv dist/index.pck dist/index-3.0.1-fr-joy.pck \
|
&& mv dist/index.pck "dist/index-${WEB_BUILD_ID}.pck" \
|
||||||
&& sed -i 's|"index.pck":|"index-3.0.1-fr-joy.pck":|; s|"focusCanvas":true,|"focusCanvas":true,"mainPack":"index-3.0.1-fr-joy.pck",|' dist/index.html \
|
&& sed -i "s|\"index.pck\":|\"index-${WEB_BUILD_ID}.pck\":|; s|\"focusCanvas\":true,|\"focusCanvas\":true,\"mainPack\":\"index-${WEB_BUILD_ID}.pck\",|" dist/index.html \
|
||||||
&& test -s dist/index.html \
|
&& test -s dist/index.html \
|
||||||
&& test -s dist/index.wasm \
|
&& test -s dist/index.wasm \
|
||||||
&& test -s dist/index-3.0.1-fr-joy.pck
|
&& test -s "dist/index-${WEB_BUILD_ID}.pck"
|
||||||
|
|
||||||
FROM alpine:3.22 AS french-content
|
FROM alpine:3.22 AS french-content
|
||||||
ARG FRENCH_PACK_VERSION=v20260615-9e5d0d4
|
ARG FRENCH_PACK_VERSION=v20260615-9e5d0d4
|
||||||
@@ -56,9 +57,15 @@ RUN apk add --no-cache ca-certificates curl \
|
|||||||
&& curl -fsSL "https://github.com/Excello-Recherche-Education/Kalulu-Languages/releases/download/${FRENCH_PACK_VERSION}/fr_FR.zip" -o /content/fr_FR.zip \
|
&& curl -fsSL "https://github.com/Excello-Recherche-Education/Kalulu-Languages/releases/download/${FRENCH_PACK_VERSION}/fr_FR.zip" -o /content/fr_FR.zip \
|
||||||
&& test -s /content/fr_FR.zip
|
&& test -s /content/fr_FR.zip
|
||||||
|
|
||||||
|
FROM alpine:3.22 AS compressed-web
|
||||||
|
RUN apk add --no-cache gzip
|
||||||
|
COPY --from=web-builder /src/dist/ /web/
|
||||||
|
RUN find /web -type f \( -name '*.js' -o -name '*.pck' -o -name '*.wasm' \) \
|
||||||
|
-exec gzip -9 -k {} \;
|
||||||
|
|
||||||
FROM nginx:1.29.1-alpine AS runtime
|
FROM nginx:1.29.1-alpine AS runtime
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY --from=web-builder /src/dist/ /usr/share/nginx/html/
|
COPY --from=compressed-web /web/ /usr/share/nginx/html/
|
||||||
COPY --from=french-content /content/fr_FR.zip /usr/share/nginx/html/content/fr_FR.zip
|
COPY --from=french-content /content/fr_FR.zip /usr/share/nginx/html/content/fr_FR.zip
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ docker compose up -d kalulu
|
|||||||
./scripts/verify-live.sh
|
./scripts/verify-live.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Le premier lancement charge environ 34 Mo d’application puis télécharge 66 Mo de contenu pédagogique depuis la même origine. Le pack est ensuite extrait et conservé localement ; cette première installation peut prendre quelques minutes. Effacer les données du site dans le navigateur réinitialise le profil et la progression.
|
Le premier lancement charge environ 45 Mo d’application compressée puis télécharge 66 Mo de contenu pédagogique depuis la même origine. Le pack est extrait directement sur le thread Web principal, par lots, puis conservé localement. L’extraction testée atteint le premier jardin en moins d’une minute, contre plus de huit minutes avec l’extracteur multithread d’origine ; le téléchargement dépend naturellement de la connexion. Effacer les données du site dans le navigateur réinitialise le profil et la progression.
|
||||||
|
|
||||||
L’image construit l’export avec Godot 4.6.3, les modèles d’export officiels et Godot-SQLite 4.8 (la version compilée pour Godot 4.6.3). Nginx sert WebAssembly avec les en-têtes COOP/COEP requis pour les threads.
|
L’image construit l’export avec Godot 4.6.3, les modèles d’export officiels et Godot-SQLite 4.8 (la version compilée pour Godot 4.6.3). Nginx sert WebAssembly avec les en-têtes COOP/COEP requis pour les threads.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
kalulu:
|
kalulu:
|
||||||
image: kalulu-web:3.0.1-fr-joy
|
image: kalulu-web:3.0.1-fr-joy-fast
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|||||||
+4
-2
@@ -33,6 +33,7 @@ func extract(zip_path: String, extract_path: String, extract_in_subfolder: bool
|
|||||||
Log.trace("FolderUnzipper: %d files found" % total_files)
|
Log.trace("FolderUnzipper: %d files found" % total_files)
|
||||||
|
|
||||||
var copied_file: int = 0
|
var copied_file: int = 0
|
||||||
|
var progress_step: int = 25 if OS.has_feature("web") else 1
|
||||||
var first_folder: String = ""
|
var first_folder: String = ""
|
||||||
var last_sub_path: String = ""
|
var last_sub_path: String = ""
|
||||||
|
|
||||||
@@ -78,9 +79,10 @@ func extract(zip_path: String, extract_path: String, extract_in_subfolder: bool
|
|||||||
file.store_buffer(data)
|
file.store_buffer(data)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
Log.trace("FolderUnzipper: Copied %s" % file_name)
|
|
||||||
copied_file += 1
|
copied_file += 1
|
||||||
file_copied.emit(copied_file, file_name)
|
if copied_file % progress_step == 0 or copied_file == total_files:
|
||||||
|
Log.trace("FolderUnzipper: Copied %s" % file_name)
|
||||||
|
file_copied.emit(copied_file, file_name)
|
||||||
|
|
||||||
close()
|
close()
|
||||||
finished.emit()
|
finished.emit()
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ server {
|
|||||||
server_name _;
|
server_name _;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
gzip_static on;
|
||||||
|
gzip_vary on;
|
||||||
|
|
||||||
add_header Cross-Origin-Opener-Policy "same-origin" always;
|
add_header Cross-Origin-Opener-Policy "same-origin" always;
|
||||||
add_header Cross-Origin-Embedder-Policy "require-corp" always;
|
add_header Cross-Origin-Embedder-Policy "require-corp" always;
|
||||||
|
|||||||
@@ -291,11 +291,17 @@ func _on_http_request_request_completed(_result: int, response_code: int, _heade
|
|||||||
Log.trace("PackageDownloader: Download completed with HTTP code %d" % response_code)
|
Log.trace("PackageDownloader: Download completed with HTTP code %d" % response_code)
|
||||||
if response_code == 200:
|
if response_code == 200:
|
||||||
mutex = Mutex.new()
|
mutex = Mutex.new()
|
||||||
thread = Thread.new()
|
|
||||||
download_label.hide()
|
download_label.hide()
|
||||||
copy_label.show()
|
copy_label.show()
|
||||||
Log.trace("PackageDownloader: Starting extraction thread")
|
if (ServerManager as ServerManagerClass).is_local_web_mode():
|
||||||
thread.start(_copy_data.bind(self))
|
# Web filesystem calls from a pthread are proxied one by one to the
|
||||||
|
# browser main thread. Extracting directly is dramatically faster.
|
||||||
|
Log.trace("PackageDownloader: Starting optimized Web extraction")
|
||||||
|
call_deferred("_copy_data", self)
|
||||||
|
else:
|
||||||
|
thread = Thread.new()
|
||||||
|
Log.trace("PackageDownloader: Starting extraction thread")
|
||||||
|
thread.start(_copy_data.bind(self))
|
||||||
else:
|
else:
|
||||||
Log.warn("PackageDownloader: Download failed with HTTP code %d" % response_code)
|
Log.warn("PackageDownloader: Download failed with HTTP code %d" % response_code)
|
||||||
error_label.show()
|
error_label.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user