Build Failed: Shutdown worker was forced killed because it kept running

Hello we have an issue when building from CLI. Building via the editor works fine when calling the same MenuItem build function but doing it inside docker file fails. It worked just fine when using 2022.3.7f1 but fails now after upgrading to 2023.2.20f1

#17 513.6 Exception: Build failed: Building player scripts failed.
#17 513.6 
#17 513.6 Error building Player: 3 errors
#17 513.6 
#17 513.6 Shutdown worker was forced killed because it kept running. Worker 1
#17 513.6 
#17 513.6 Error building Player: Shutdown worker was forced killed because it kept running. Worker 1
#17 513.6 
#17 513.6 LOG END
#17 513.6   at CCGKit.Builder.BuildGameClient () [0x0012e] in /app/Assets/Scripts/Editor/Builder.cs:82 

Dockerfile

FROM unityci/editor:ubuntu-2023.2.20f1-webgl-3.1.0 AS unitybuild

RUN mkdir -p /root/Library/Logs/Unity
RUN touch /root/Library/Logs/Unity/Editor.log

ARG UNITY_SERIAL
ARG UNITY_EMAIL
ARG UNITY_PASSWORD

WORKDIR /app
COPY ./Assets /app/Assets 
COPY ./Packages /app/Packages 
COPY ./ProjectSettings /app/ProjectSettings 

# output folder
RUN mkdir -p /app/Builds

RUN /usr/bin/xvfb-run --auto-servernum --server-args='-screen 0 1024x768x16'  $UNITY_PATH/Editor/Unity \
  -quit \
  -batchmode \
  -nographics \
  -username $UNITY_EMAIL \
  -password $UNITY_PASSWORD \
  -serial $UNITY_SERIAL \
  -projectPath '.' \
  -executeMethod CCGKit.Builder.BuildGameClient 

RUN ls Builds

docker-compose.yaml

version: "3.8"
services:
  client:
    build:
      context: ./
      dockerfile: ./Deploy/Client.Dockerfile
      network: host
      args:
       - UNITY_SERIAL=${UNITY_SERIAL}
       - UNITY_EMAIL=${UNITY_EMAIL}
       - UNITY_PASSWORD=${UNITY_PASSWORD}
    deploy:
      restart_policy:
        condition: on-failure
        delay: 5s
    ports:
      - "80:80"

Builder function

[MenuItem("Tools/COOM/[Internal] Build webgl CI", false, 100)]
		public static void BuildGameClient()
		{
			var levels = new string[] {
					 "Assets/Scenes/Game.unity"
				};
			EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
			PlayerSettings.WebGL.emscriptenArgs = "--profiling-funcs";
			PlayerSettings.WebGL.nameFilesAsHashes = false;
			EditorUserSettings.desiredImportWorkerCount = 6;
			EditorUserSettings.standbyImportWorkerCount = 6;
			EditorUserSettings.idleImportWorkerShutdownDelayMilliseconds = 12000000;
			EditorSettings.refreshImportMode = AssetDatabase.RefreshImportMode.OutOfProcessPerQueue;
			// EditorUserSettings.desiredImportWorkerCount = 0;
			// EditorUserSettings.standbyImportWorkerCount = 0;
			// EditorSettings.refreshImportMode = AssetDatabase.RefreshImportMode.InProcess;
			PlayerSettings.SplashScreen.show = false;
			PlayerSettings.SplashScreen.showUnityLogo = false;
			// PlayerSettings.WebGL.threadsSupport = true;
			// PlayerSettings.WebGL.emscriptenArgs = "-s WASM_MEM_MAX=2048MB --profiling-funcs";
			var res = BuildPipeline.BuildPlayer(new BuildPlayerOptions()
			{
				scenes = levels,
				target = BuildTarget.WebGL,
				targetGroup = BuildTargetGroup.WebGL,
				subtarget = (int)StandaloneBuildSubtarget.Player,
				options = BuildOptions.StrictMode,
				locationPathName = "Builds/GameClient"
			});

			if (res.summary.result == BuildResult.Failed)
			{
				var msg = "";
				foreach (var step in res.steps)
				{
					foreach (var item in step.messages)
					{
						if (item.type == LogType.Error)
						{
							msg += item.content + "\n\n";
						}
					}
				}
				msg += "LOG END";
				throw new System.Exception("Build failed: " + msg);
			}
			Debug.Log("Build BuildGameClient done");
		}