diff --git a/.env b/.env index 4bf6a61a1..9734c8e06 100644 --- a/.env +++ b/.env @@ -34,6 +34,7 @@ _APP_SMTP_USERNAME= _APP_SMTP_PASSWORD= _APP_STORAGE_LIMIT=10000000 _APP_FUNCTIONS_TIMEOUT=900 +_APP_FUNCTIONS_BUILD_TIMEOUT=900 _APP_FUNCTIONS_CONTAINERS=10 _APP_FUNCTIONS_CPUS=4 _APP_FUNCTIONS_MEMORY=2000 diff --git a/app/config/variables.php b/app/config/variables.php index 1e1009841..28072ee4a 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -417,6 +417,15 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_FUNCTIONS_BUILD_TIMEOUT', + 'description' => 'The maximum number of seconds allowed as a timeout value when building a new function. The default value is 900 seconds.', + 'introduction' => '0.12.0', + 'default' => '900', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_FUNCTIONS_CONTAINERS', 'description' => 'The maximum number of containers Appwrite is allowed to keep alive in the background for function environments. Running containers allow faster execution time as there is no need to recreate each container every time a function gets executed. The default value is 10.', diff --git a/app/executor.php b/app/executor.php index 48e98bac9..4c485d38a 100644 --- a/app/executor.php +++ b/app/executor.php @@ -319,6 +319,7 @@ function runBuildStage(string $tagID, Document $function, string $projectID, Dat $tagPath = $tag->getAttribute('path', ''); $tagPathTarget = '/tmp/project-' . $projectID . '/' . $tag->getId() . '/code.tar.gz'; $tagPathTargetDir = \pathinfo($tagPathTarget, PATHINFO_DIRNAME); + $container = 'build-stage-' . $tag->getId(); // Perform various checks @@ -392,7 +393,7 @@ function runBuildStage(string $tagID, Document $function, string $projectID, Dat ] ); - if (empty($id)) { + if (empty($id)) { throw new Exception('Failed to start build container'); } @@ -442,7 +443,7 @@ function runBuildStage(string $tagID, Document $function, string $projectID, Dat command: ['sh', '-c', 'cd /usr/local/src && ./build.sh'], stdout: $buildStdout, stderr: $buildStderr, - timeout: 600 //TODO: Make this configurable + timeout: App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900) ); if (!$buildSuccess) { diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 82e99d9fd..5ce9ee87d 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -101,6 +101,7 @@ services: - _APP_STORAGE_ANTIVIRUS_HOST - _APP_STORAGE_ANTIVIRUS_PORT - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY @@ -290,6 +291,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY diff --git a/docker-compose.yml b/docker-compose.yml index c26b45943..3edf3daba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -121,6 +121,7 @@ services: - _APP_USAGE_STATS - _APP_STORAGE_LIMIT - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY @@ -330,6 +331,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_RUNTIMES - _APP_FUNCTIONS_CPUS @@ -381,6 +383,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_RUNTIMES - _APP_FUNCTIONS_CPUS diff --git a/tests/resources/docker/docker-compose.yml b/tests/resources/docker/docker-compose.yml index 76d62317a..3483f16e0 100644 --- a/tests/resources/docker/docker-compose.yml +++ b/tests/resources/docker/docker-compose.yml @@ -84,6 +84,7 @@ services: - _APP_STORAGE_ANTIVIRUS=disabled - _APP_STORAGE_LIMIT - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY @@ -243,6 +244,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_FUNCTIONS_TIMEOUT + - _APP_FUNCTIONS_BUILD_TIMEOUT - _APP_FUNCTIONS_CONTAINERS - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY