@@ -332,16 +332,33 @@ function runtimeBootstrapPhpIniEntries(spec: RuntimeCreateSpec): Record<string,
332332}
333333
334334function pluginRuntimeBootstrapPhpIniEntries ( spec : RuntimeCreateSpec ) : Record < string , string > | undefined {
335- return pluginRuntimePhpEntries ( spec , "bootstrapIniEntries" )
335+ const memoryLimit = pluginRuntimePhpMemoryLimit ( spec )
336+ return {
337+ ...( memoryLimit ? { memory_limit : memoryLimit } : { } ) ,
338+ ...( pluginRuntimePhpEntries ( spec , "bootstrapIniEntries" ) ?? { } ) ,
339+ }
336340}
337341
338342function pluginRuntimePhpIniEntries ( spec : RuntimeCreateSpec ) : Record < string , string > | undefined {
343+ const memoryLimit = pluginRuntimePhpMemoryLimit ( spec )
339344 return {
340345 ...DEFAULT_RUNTIME_PHP_INI_ENTRIES ,
346+ ...( memoryLimit ? { memory_limit : memoryLimit } : { } ) ,
341347 ...( pluginRuntimePhpEntries ( spec , "iniEntries" ) ?? { } ) ,
342348 }
343349}
344350
351+ function pluginRuntimePhpMemoryLimit ( spec : RuntimeCreateSpec ) : string | undefined {
352+ const pluginRuntime = spec . metadata ?. recipe && typeof spec . metadata . recipe === "object" && ! Array . isArray ( spec . metadata . recipe )
353+ ? ( spec . metadata . recipe as { inputs ?: { pluginRuntime ?: unknown } } ) . inputs ?. pluginRuntime
354+ : undefined
355+ const php = pluginRuntime && typeof pluginRuntime === "object" && ! Array . isArray ( pluginRuntime )
356+ ? ( pluginRuntime as { php ?: Record < string , unknown > } ) . php
357+ : undefined
358+ const memoryLimit = php ?. memoryLimit
359+ return typeof memoryLimit === "string" && / ^ [ 0 - 9 ] + [ K M G ] ? $ / . test ( memoryLimit ) ? memoryLimit : undefined
360+ }
361+
345362function pluginRuntimePhpEntries ( spec : RuntimeCreateSpec , key : "iniEntries" | "bootstrapIniEntries" ) : Record < string , string > | undefined {
346363 const pluginRuntime = spec . metadata ?. recipe && typeof spec . metadata . recipe === "object" && ! Array . isArray ( spec . metadata . recipe )
347364 ? ( spec . metadata . recipe as { inputs ?: { pluginRuntime ?: unknown } } ) . inputs ?. pluginRuntime
0 commit comments