mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Resolve merge conflicts
This commit is contained in:
@@ -83,7 +83,8 @@ _APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes
|
||||
_APP_EXECUTOR_SECRET=your-secret-key
|
||||
_APP_EXECUTOR_HOST=http://proxy/v1
|
||||
_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1
|
||||
_APP_SITES_FRAMEWORKS=sveltekit,nextjs
|
||||
_APP_SITES_RUNTIMES=static-1,node-22
|
||||
_APP_SITES_FRAMEWORKS=sveltekit,nextjs,static
|
||||
_APP_MAINTENANCE_INTERVAL=86400
|
||||
_APP_MAINTENANCE_DELAY=
|
||||
_APP_MAINTENANCE_RETENTION_CACHE=2592000
|
||||
|
||||
+23
-12
@@ -3413,17 +3413,6 @@ $projectCollections = array_merge([
|
||||
'default' => APP_FUNCTION_SPECIFICATION_DEFAULT,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('scopes'),
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => [],
|
||||
'array' => true,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('fallbackRedirect'),
|
||||
'type' => Database::VAR_STRING,
|
||||
@@ -3434,7 +3423,29 @@ $projectCollections = array_merge([
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
]
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('serveRuntime'),
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 2048,
|
||||
'signed' => true,
|
||||
'required' => true,
|
||||
'default' => '',
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('buildRuntime'),
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 2048,
|
||||
'signed' => true,
|
||||
'required' => true,
|
||||
'default' => '',
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
|
||||
+62
-13
@@ -4,27 +4,76 @@
|
||||
* List of Appwrite Sites supported frameworks
|
||||
*/
|
||||
|
||||
const TEMPLATE_RUNTIMES = [
|
||||
'NODE' => [
|
||||
'name' => 'node',
|
||||
'versions' => ['22', '21.0', '20.0', '19.0', '18.0', '16.0', '14.5']
|
||||
],
|
||||
'PYTHON' => [
|
||||
'name' => 'python',
|
||||
'versions' => ['3.12', '3.11', '3.10', '3.9', '3.8']
|
||||
],
|
||||
'DART' => [
|
||||
'name' => 'dart',
|
||||
'versions' => ['3.5', '3.3', '3.1', '3.0', '2.19', '2.18', '2.17', '2.16', '2.16']
|
||||
],
|
||||
'GO' => [
|
||||
'name' => 'go',
|
||||
'versions' => ['1.23']
|
||||
],
|
||||
'PHP' => [
|
||||
'name' => 'php',
|
||||
'versions' => ['8.3', '8.2', '8.1', '8.0']
|
||||
],
|
||||
'DENO' => [
|
||||
'name' => 'deno',
|
||||
'versions' => ['2.0', '1.46', '1.40', '1.35', '1.24', '1.21']
|
||||
],
|
||||
'BUN' => [
|
||||
'name' => 'bun',
|
||||
'versions' => ['1.1', '1.0']
|
||||
],
|
||||
'RUBY' => [
|
||||
'name' => 'ruby',
|
||||
'versions' => ['3.3', '3.2', '3.1', '3.0']
|
||||
],
|
||||
];
|
||||
|
||||
function getVersions(array $versions, string $prefix)
|
||||
{
|
||||
return array_map(function ($version) use ($prefix) {
|
||||
return $prefix . '-' . $version;
|
||||
}, $versions);
|
||||
}
|
||||
|
||||
return [
|
||||
"sveltekit" => [
|
||||
'sveltekit' => [
|
||||
'key' => 'sveltekit',
|
||||
'name' => 'SvelteKit',
|
||||
'logo' => 'sveltekit.png',
|
||||
'defaultRuntime' => 'node-20.0',
|
||||
'runtimes' => [
|
||||
'node-16.0',
|
||||
'node-18.0',
|
||||
'node-20.0'
|
||||
],
|
||||
'defaultServeRuntime' => 'node-22',
|
||||
'serveRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node'),
|
||||
'defaultBuildRuntime' => 'node-22',
|
||||
'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node')
|
||||
],
|
||||
"nextjs" => [
|
||||
'nextjs' => [
|
||||
'key' => 'nextjs',
|
||||
'name' => 'Next.js',
|
||||
'logo' => 'nextjs.png',
|
||||
'defaultRuntime' => 'node-20.0',
|
||||
'runtimes' => [
|
||||
'node-16.0',
|
||||
'node-18.0',
|
||||
'node-20.0'
|
||||
'defaultServeRuntime' => 'node-22',
|
||||
'serveRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node'),
|
||||
'defaultBuildRuntime' => 'node-22',
|
||||
'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node')
|
||||
],
|
||||
'static' => [
|
||||
'key' => 'static',
|
||||
'name' => 'Static',
|
||||
'logo' => 'static.png',
|
||||
'defaultServeRuntime' => 'static-1',
|
||||
'serveRuntimes' => [
|
||||
'static-1'
|
||||
],
|
||||
'defaultBuildRuntime' => 'node-22',
|
||||
'buildRuntimes' => getVersions(TEMPLATE_RUNTIMES['NODE']['versions'], 'node')
|
||||
]
|
||||
];
|
||||
|
||||
@@ -54,20 +54,14 @@ App::post('/v1/proxy/rules')
|
||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||
$functionsDomain = System::getEnv('_APP_DOMAIN_FUNCTIONS', '');
|
||||
|
||||
switch ($resourceType) {
|
||||
case 'function':
|
||||
if (str_ends_with($domain, $functionsDomain)) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.');
|
||||
}
|
||||
break;
|
||||
case 'site':
|
||||
if (str_ends_with($domain, $sitesDomain)) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions domain or it\'s subdomain to specific resource. Please use different domain.');
|
||||
}
|
||||
break;
|
||||
if (
|
||||
($functionsDomain !== '' && str_ends_with($domain, $functionsDomain)) ||
|
||||
($sitesDomain !== '' && str_ends_with($domain, $sitesDomain))
|
||||
) {
|
||||
// TODO: Refactor later
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'You cannot assign your functions or sites domain or their subdomains to a specific resource. Please use a different domain.');
|
||||
}
|
||||
|
||||
|
||||
if ($domain === 'localhost' || $domain === APP_HOSTNAME_INTERNAL) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'This domain name is not allowed. Please pick another one.');
|
||||
}
|
||||
@@ -111,8 +105,7 @@ App::post('/v1/proxy/rules')
|
||||
break;
|
||||
case 'site':
|
||||
if (empty($resourceId)) {
|
||||
// todo: use site relecant exception
|
||||
throw new Exception(Exception::FUNCTION_NOT_FOUND);
|
||||
throw new Exception(Exception::SITE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$site = $dbForProject->getDocument('sites', $resourceId);
|
||||
@@ -378,3 +371,40 @@ App::patch('/v1/proxy/rules/:ruleId/verification')
|
||||
|
||||
$response->dynamic($rule, Response::MODEL_PROXY_RULE);
|
||||
});
|
||||
|
||||
App::get('/v1/proxy/subdomains')
|
||||
->desc('Check if subdomain is available')
|
||||
->groups(['api', 'proxy'])
|
||||
->label('scope', 'rules.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'proxy')
|
||||
->label('sdk.method', 'checkSubdomain')
|
||||
->label('sdk.description', '/docs/references/proxy/check-subdomain.md')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('resourceType', null, new WhiteList(['function', 'site']), 'Action definition for the rule. Possible values are "function" and "site"')
|
||||
->param('subdomain', '', new Text(256), 'Subdomain name.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->action(function (string $resourceType, string $subdomain, Response $response, Database $dbForConsole) {
|
||||
//TODO: Add tests for this endpoint
|
||||
$resourceDomain = $resourceType === 'site' ? System::getEnv('_APP_DOMAIN_SITES', '') : System::getEnv('_APP_DOMAIN_FUNCTIONS', '');
|
||||
$domain = $subdomain . '.' . $resourceDomain;
|
||||
|
||||
$document = $dbForConsole->findOne('rules', [
|
||||
Query::equal('domain', [$domain]),
|
||||
]);
|
||||
|
||||
if ($document && !$document->isEmpty()) {
|
||||
return $response->json([
|
||||
'success' => false,
|
||||
'message' => 'Subdomain is already taken.'
|
||||
], Response::STATUS_CODE_CONFLICT);
|
||||
}
|
||||
|
||||
return $response->json([
|
||||
'success' => true,
|
||||
'message' => 'Subdomain is available.'
|
||||
], Response::STATUS_CODE_OK);
|
||||
});
|
||||
|
||||
@@ -200,11 +200,10 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId
|
||||
'resourceInternalId' => $resourceInternalId,
|
||||
'resourceType' => $resourceCollection,
|
||||
'entrypoint' => $resource->getAttribute('entrypoint', ''),
|
||||
'commands' => $resource->getAttribute('commands', []),
|
||||
'commands' => $resource->getAttribute('commands', ''),
|
||||
'installCommand' => $resource->getAttribute('installCommand', ''),
|
||||
'buildCommand' => $resource->getAttribute('buildCommand', ''),
|
||||
'outputDirectory' => $resource->getAttribute('outputDirectory', ''),
|
||||
'fallbackRedirect' => $resource->getAttribute('fallbackRedirect', ''),
|
||||
'type' => 'vcs',
|
||||
'installationId' => $installationId,
|
||||
'installationInternalId' => $installationInternalId,
|
||||
|
||||
@@ -142,23 +142,17 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
|
||||
throw new AppwriteException(AppwriteException::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$version = $resource->getAttribute('version', 'v2');
|
||||
$version = match($type) {
|
||||
'function' => $resource->getAttribute('version', 'v2'),
|
||||
'site' => 'v4'
|
||||
};
|
||||
|
||||
$runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []);
|
||||
$spec = Config::getParam('runtime-specifications')[$resource->getAttribute('specification', APP_FUNCTION_SPECIFICATION_DEFAULT)];
|
||||
|
||||
//todo: have runtime configs for sites
|
||||
$runtime = match($type) {
|
||||
'function' => (isset($runtimes[$resource->getAttribute('runtime', '')])) ? $runtimes[$resource->getAttribute('runtime', '')] : null,
|
||||
'site' => [
|
||||
'key' => 'static-for-now',
|
||||
'name' => 'Static',
|
||||
'logo' => 'node.png',
|
||||
'startCommand' => null,
|
||||
'version' => 'v1',
|
||||
'base' => 'openruntimes/static:v4-:1.0',
|
||||
'image' => 'openruntimes/static:v4-:1.0',
|
||||
'supports' => [System::X86, System::ARM64, System::ARMV7, System::ARMV8]
|
||||
],
|
||||
'function' => $runtimes[$resource->getAttribute('runtime')] ?? null,
|
||||
'site' => $runtimes[$resource->getAttribute('serveRuntime')] ?? null,
|
||||
default => null
|
||||
};
|
||||
|
||||
|
||||
@@ -801,7 +801,7 @@ $image = $this->getParam('image', '');
|
||||
<<: *x-logging
|
||||
restart: unless-stopped
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.6.11
|
||||
image: openruntimes/executor:0.6.25
|
||||
networks:
|
||||
- appwrite
|
||||
- runtimes
|
||||
|
||||
Generated
+7
-7
@@ -157,16 +157,16 @@
|
||||
},
|
||||
{
|
||||
"name": "appwrite/php-runtimes",
|
||||
"version": "0.16.2",
|
||||
"version": "0.16.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/runtimes.git",
|
||||
"reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9"
|
||||
"reference": "7e4741337b9373f77210396e68eca539018cabd1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/appwrite/runtimes/zipball/c33005e3eaaf2d427e9fd1077d5335e31f4d36f9",
|
||||
"reference": "c33005e3eaaf2d427e9fd1077d5335e31f4d36f9",
|
||||
"url": "https://api.github.com/repos/appwrite/runtimes/zipball/7e4741337b9373f77210396e68eca539018cabd1",
|
||||
"reference": "7e4741337b9373f77210396e68eca539018cabd1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -206,9 +206,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/appwrite/runtimes/issues",
|
||||
"source": "https://github.com/appwrite/runtimes/tree/0.16.2"
|
||||
"source": "https://github.com/appwrite/runtimes/tree/0.16.4"
|
||||
},
|
||||
"time": "2024-10-09T15:02:52+00:00"
|
||||
"time": "2024-10-26T10:39:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "beberlei/assert",
|
||||
@@ -7029,5 +7029,5 @@
|
||||
"platform-overrides": {
|
||||
"php": "8.3"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
||||
+3
-2
@@ -162,6 +162,7 @@ services:
|
||||
- _APP_FUNCTIONS_CPUS
|
||||
- _APP_FUNCTIONS_MEMORY
|
||||
- _APP_FUNCTIONS_RUNTIMES
|
||||
- _APP_SITES_RUNTIMES
|
||||
- _APP_SITES_FRAMEWORKS
|
||||
- _APP_SITES_CPUS
|
||||
- _APP_SITES_MEMORY
|
||||
@@ -887,7 +888,7 @@ services:
|
||||
hostname: exc1
|
||||
<<: *x-logging
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.6.11
|
||||
image: openruntimes/executor:0.6.25
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
@@ -906,7 +907,7 @@ services:
|
||||
- OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME
|
||||
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD
|
||||
- OPR_EXECUTOR_ENV=$_APP_ENV
|
||||
- OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES
|
||||
- OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES,$_APP_SITES_RUNTIMES
|
||||
- OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET
|
||||
- OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4
|
||||
- OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG
|
||||
|
||||
@@ -596,7 +596,8 @@ class Builds extends Action
|
||||
entrypoint: $deployment->getAttribute('entrypoint', 'package.json'), // TODO: change this later so that sites don't need to have an entrypoint
|
||||
destination: APP_STORAGE_BUILDS . "/app-{$project->getId()}",
|
||||
variables: $vars,
|
||||
command: $command
|
||||
command: $command,
|
||||
outputDirectory: $resource->getAttribute('outputDirectory', '')
|
||||
);
|
||||
} catch (\Throwable $error) {
|
||||
$err = $error;
|
||||
@@ -834,8 +835,8 @@ class Builds extends Action
|
||||
$runtimes = Config::getParam($version === 'v2' ? 'runtimes-v2' : 'runtimes', []);
|
||||
$key = $resource->getAttribute('runtime');
|
||||
$runtime = match ($resource->getCollection()) {
|
||||
'functions' => $runtimes[$key] ?? null,
|
||||
'sites' => $runtimes['node-18.0'] ?? null, //todo: fix hardcode
|
||||
'functions' => $runtimes[$resource->getAttribute('runtime')] ?? null,
|
||||
'sites' => $runtimes[$resource->getAttribute('buildRuntime')] ?? null,
|
||||
default => null
|
||||
};
|
||||
if (\is_null($runtime)) {
|
||||
|
||||
@@ -18,12 +18,12 @@ use Utopia\Database\Document;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
use Utopia\Swoole\Request;
|
||||
use Utopia\System\System;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\Text;
|
||||
@@ -66,7 +66,7 @@ class CreateSite extends Base
|
||||
->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true)
|
||||
->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true)
|
||||
->param('fallbackRedirect', '', new Text(8192, 0), 'Fallback Redirect URL for site in case a route is not found.', true)
|
||||
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) //TODO: Update description of scopes
|
||||
->param('subdomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true)
|
||||
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
|
||||
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true)
|
||||
->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the site.', true)
|
||||
@@ -94,8 +94,27 @@ class CreateSite extends Base
|
||||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, array $scopes, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github)
|
||||
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $fallbackRedirect, string $subdomain, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github)
|
||||
{
|
||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||
$ruleId = '';
|
||||
$routeSubdomain = '';
|
||||
$domain = '';
|
||||
|
||||
if (!empty($sitesDomain)) {
|
||||
$ruleId = ID::unique();
|
||||
$routeSubdomain = $subdomain ?? ID::unique();
|
||||
$domain = "{$routeSubdomain}.{$sitesDomain}";
|
||||
|
||||
$subdomain = Authorization::skip(fn () => $dbForConsole->findOne('rules', [
|
||||
Query::equal('domain', [$domain])
|
||||
]));
|
||||
|
||||
if (!empty($subdomain)) {
|
||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.');
|
||||
}
|
||||
}
|
||||
|
||||
$siteId = ($siteId == 'unique()') ? ID::unique() : $siteId;
|
||||
|
||||
$allowList = \array_filter(\explode(',', System::getEnv('_APP_SITES_FRAMEWORKS', '')));
|
||||
@@ -141,7 +160,6 @@ class CreateSite extends Base
|
||||
'buildCommand' => $buildCommand,
|
||||
'outputDirectory' => $outputDirectory,
|
||||
'fallbackRedirect' => $fallbackRedirect,
|
||||
'scopes' => $scopes,
|
||||
'search' => implode(' ', [$siteId, $name, $framework]),
|
||||
'installationId' => $installation->getId(),
|
||||
'installationInternalId' => $installation->getInternalId(),
|
||||
@@ -151,7 +169,9 @@ class CreateSite extends Base
|
||||
'providerBranch' => $providerBranch,
|
||||
'providerRootDirectory' => $providerRootDirectory,
|
||||
'providerSilentMode' => $providerSilentMode,
|
||||
'specification' => $specification
|
||||
'specification' => $specification,
|
||||
'buildRuntime' => Config::getParam('frameworks', [])[$framework]['defaultBuildRuntime'],
|
||||
'serveRuntime' => Config::getParam('frameworks', [])[$framework]['defaultServeRuntime'],
|
||||
]));
|
||||
|
||||
// Git connect logic
|
||||
@@ -215,12 +235,7 @@ class CreateSite extends Base
|
||||
->setTemplate($template);
|
||||
}
|
||||
|
||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||
if (!empty($sitesDomain)) {
|
||||
$ruleId = ID::unique();
|
||||
$routeSubdomain = ID::unique();
|
||||
$domain = "{$routeSubdomain}.{$sitesDomain}";
|
||||
|
||||
$rule = Authorization::skip(
|
||||
fn () => $dbForConsole->createDocument('rules', new Document([
|
||||
'$id' => $ruleId,
|
||||
|
||||
@@ -34,17 +34,30 @@ class Framework extends Model
|
||||
'default' => '',
|
||||
'example' => 'sveltekit.png',
|
||||
])
|
||||
->addRule('defaultRuntime', [
|
||||
->addRule('defaultServeRuntime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Default runtime version.',
|
||||
'default' => '',
|
||||
'example' => 'node-20.0',
|
||||
'example' => 'static-1',
|
||||
])
|
||||
->addRule('runtimes', [
|
||||
->addRule('serveRuntimes', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'List of supported runtime versions.',
|
||||
'default' => '',
|
||||
'example' => 'node-16.0',
|
||||
'example' => 'static-1',
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('defaultBuildRuntime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Default runtime version.',
|
||||
'default' => '',
|
||||
'example' => 'node-22',
|
||||
])
|
||||
->addRule('buildRuntimes', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'List of supported runtime versions.',
|
||||
'default' => '',
|
||||
'example' => 'node-21.0',
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
|
||||
@@ -61,7 +61,7 @@ class Func extends Model
|
||||
])
|
||||
->addRule('runtime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Function execution runtime.',
|
||||
'description' => 'Function execution and build runtime.',
|
||||
'default' => '',
|
||||
'example' => 'python-3.8',
|
||||
])
|
||||
|
||||
@@ -58,13 +58,6 @@ class Site extends Model
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('scopes', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Allowed permission scopes.',
|
||||
'default' => [],
|
||||
'example' => 'users.read',
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('vars', [
|
||||
'type' => Response::MODEL_VARIABLE,
|
||||
'description' => 'Site variables.',
|
||||
@@ -138,6 +131,18 @@ class Site extends Model
|
||||
'default' => APP_SITE_SPECIFICATION_DEFAULT,
|
||||
'example' => APP_SITE_SPECIFICATION_DEFAULT,
|
||||
])
|
||||
->addRule('buildRuntime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site build runtime.',
|
||||
'default' => '',
|
||||
'example' => 'node-22',
|
||||
])
|
||||
->addRule('serveRuntime', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site serve runtime.',
|
||||
'default' => '',
|
||||
'example' => 'static-1',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class Executor
|
||||
string $destination = '',
|
||||
array $variables = [],
|
||||
string $command = null,
|
||||
string $outputDirectory = ''
|
||||
) {
|
||||
$runtimeId = "$projectId-$deploymentId-build";
|
||||
$route = "/runtimes";
|
||||
@@ -90,6 +91,7 @@ class Executor
|
||||
'memory' => $memory,
|
||||
'version' => $version,
|
||||
'timeout' => $timeout,
|
||||
'outputDirectory' => $outputDirectory
|
||||
];
|
||||
|
||||
$response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
||||
|
||||
@@ -467,7 +467,7 @@ class HealthCustomServerTest extends Scope
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('/CN=appwrite.io', $response['body']['name']);
|
||||
$this->assertEquals('appwrite.io', $response['body']['subjectSN']);
|
||||
$this->assertEquals("Let's Encrypt", $response['body']['issuerOrganisation']);
|
||||
$this->assertEquals('Google Trust Services', $response['body']['issuerOrganisation']);
|
||||
$this->assertIsInt($response['body']['validFrom']);
|
||||
$this->assertIsInt($response['body']['validTo']);
|
||||
|
||||
|
||||
@@ -44,5 +44,15 @@ class ProjectsCustomServerTest extends Scope
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// prevent sites domain
|
||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/proxy/rules', $headers, [
|
||||
'resourceType' => 'api',
|
||||
'domain' => $sitesDomain,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user