From 683a691bf93ae8c04ee6b1f656ef994411be0e11 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 4 Sep 2022 22:05:30 +0200 Subject: [PATCH 001/120] ci: update github actions to use github hosted runners --- .github/workflows/tests.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2ed2b65ff..64f39013f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: [pull_request] jobs: tests: name: Unit & E2E - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout repository @@ -23,12 +23,11 @@ jobs: # Upstream bug causes buildkit pulls to fail so prefetch base images # https://github.com/moby/moby/issues/41864 run: | - echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env docker pull composer:2.0 docker pull php:8.0-cli-alpine docker compose build --progress=plain docker compose up -d - sleep 10 + sleep 30 - name: Doctor run: docker compose exec -T appwrite doctor @@ -37,10 +36,3 @@ jobs: - name: Run Tests run: docker compose exec -T appwrite test --debug - - - name: Teardown - if: always() - run: | - docker ps -aq | xargs docker rm --force || true - docker volume prune --force || true - docker network prune --force || true \ No newline at end of file From bcd05bf5a7944b8f16c1f3f02e34a2b61d97e91c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 4 Sep 2022 22:23:38 +0200 Subject: [PATCH 002/120] ci: force buildkit and settings --- .github/workflows/tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 64f39013f..265292961 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,9 +23,13 @@ jobs: # Upstream bug causes buildkit pulls to fail so prefetch base images # https://github.com/moby/moby/issues/41864 run: | + export COMPOSE_INTERACTIVE_NO_CLI + export DOCKER_BUILDKIT=1 + export COMPOSE_DOCKER_CLI_BUILD=1 + export BUILDKIT_PROGRESS=plain docker pull composer:2.0 docker pull php:8.0-cli-alpine - docker compose build --progress=plain + docker compose build docker compose up -d sleep 30 - name: Doctor From 349833573fd2dd4d412197f6f4ab23a13f5e1843 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 04:51:08 +0000 Subject: [PATCH 003/120] region environment variables --- .env | 3 +++ Dockerfile | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 227ea1067..5b688cf87 100644 --- a/.env +++ b/.env @@ -81,6 +81,9 @@ _APP_USAGE_DATABASE_INTERVAL=15 _APP_USAGE_STATS=enabled _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= +_APP_REGION_DEFAULT=default +_APP_REGIIONS=default +_APP_REGION_DISABLED= DOCKERHUB_PULL_USERNAME= DOCKERHUB_PULL_PASSWORD= DOCKERHUB_PULL_EMAIL= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a7cae3850..97fb51eb0 100755 --- a/Dockerfile +++ b/Dockerfile @@ -255,7 +255,10 @@ ENV _APP_SERVER=swoole \ _APP_MAINTENANCE_RETENTION_ABUSE=86400 \ _APP_MAINTENANCE_INTERVAL=86400 \ _APP_LOGGING_PROVIDER= \ - _APP_LOGGING_CONFIG= + _APP_LOGGING_CONFIG= \ + _APP_REGIONS=default \ + _APP_REGION_DEFAULT=default \ + _APP_REGION_DISABLED= RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone From fafef03512c8292586b493dfc8f93caf962d8c5b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 04:53:46 +0000 Subject: [PATCH 004/120] region attribute on project --- app/config/collections.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/config/collections.php b/app/config/collections.php index 633e2c33b..102c8706a 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -523,6 +523,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('region'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('description'), 'type' => Database::VAR_STRING, From 119344031a7d2240cd10cf8203ff22c889085acd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 05:04:16 +0000 Subject: [PATCH 005/120] region on endpoint --- app/controllers/api/projects.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 8dec0ba0c..adc1e9007 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -58,6 +58,7 @@ App::post('/v1/projects') ->param('projectId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. 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.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('region', '', new Whitelist([App::getEnv('_APP_REGIONS', [])]), 'Project URL.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) @@ -70,7 +71,7 @@ App::post('/v1/projects') ->inject('response') ->inject('dbForConsole') ->inject('dbForProject') - ->action(function (string $projectId, string $name, string $teamId, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Database $dbForProject) { + ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Database $dbForProject) { $team = $dbForConsole->getDocument('teams', $teamId); @@ -102,6 +103,7 @@ App::post('/v1/projects') 'name' => $name, 'teamInternalId' => $team->getInternalId(), 'teamId' => $team->getId(), + 'region' => $region, 'description' => $description, 'logo' => $logo, 'url' => $url, @@ -364,6 +366,7 @@ App::patch('/v1/projects/:projectId') ->label('sdk.response.model', Response::MODEL_PROJECT) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') + ->param('region', '', new Whitelist([App::getEnv('_APP_REGIONS', [])]), 'Project URL.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) @@ -375,7 +378,7 @@ App::patch('/v1/projects/:projectId') ->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole) { + ->action(function (string $projectId, string $name, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole) { $project = $dbForConsole->getDocument('projects', $projectId); @@ -385,6 +388,7 @@ App::patch('/v1/projects/:projectId') $project = $dbForConsole->updateDocument('projects', $project->getId(), $project ->setAttribute('name', $name) + ->setAttribute('region', $region) ->setAttribute('description', $description) ->setAttribute('logo', $logo) ->setAttribute('url', $url) From 8450a0c213e861df3412c0ca223ff62ef68c57e7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 05:24:46 +0000 Subject: [PATCH 006/120] region in UI --- .env | 2 +- Dockerfile | 2 +- app/controllers/web/console.php | 6 ++++++ app/views/console/comps/header.phtml | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 5b688cf87..951b3cf56 100644 --- a/.env +++ b/.env @@ -83,7 +83,7 @@ _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= _APP_REGION_DEFAULT=default _APP_REGIIONS=default -_APP_REGION_DISABLED= +_APP_REGIONS_DISABLED= DOCKERHUB_PULL_USERNAME= DOCKERHUB_PULL_PASSWORD= DOCKERHUB_PULL_EMAIL= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 97fb51eb0..339c80e06 100755 --- a/Dockerfile +++ b/Dockerfile @@ -258,7 +258,7 @@ ENV _APP_SERVER=swoole \ _APP_LOGGING_CONFIG= \ _APP_REGIONS=default \ _APP_REGION_DEFAULT=default \ - _APP_REGION_DISABLED= + _APP_REGIONS_DISABLED= RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 864ed535f..361702472 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -28,6 +28,12 @@ App::shutdown() $header = new View(__DIR__ . '/../../views/console/comps/header.phtml'); $footer = new View(__DIR__ . '/../../views/console/comps/footer.phtml'); + $header + ->setParam('regions', App::getEnv('_APP_REGIONS', [])) + ->setParam('disabledRegions', App::getEnv('_APP_REGIONS_DISABLED', [])) + ->setParam('defaultRegion', App::getEnv('_APP_REGION_DEFAULT', 'default')) + ; + $footer ->setParam('home', App::getEnv('_APP_HOME', '')) ->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN')) diff --git a/app/views/console/comps/header.phtml b/app/views/console/comps/header.phtml index 09fe421c7..6e56c7c35 100644 --- a/app/views/console/comps/header.phtml +++ b/app/views/console/comps/header.phtml @@ -1,3 +1,8 @@ +getParam('regions', []); +$disabledRegions = $this->getParam('disabledRegions', []); +$defaultRegion = $this->getParam('defaultRegion', []); +?>