Fix install task
This commit is contained in:
parent
ec174c179f
commit
ece93a14e5
4 changed files with 40 additions and 34 deletions
|
@ -1024,11 +1024,19 @@ return [
|
|||
'name' => '_APP_MIGRATIONS_FIREBASE_CLIENT_ID',
|
||||
'description' => 'Google OAuth client ID. You can find it in your GCP application settings.',
|
||||
'introduction' => '1.4.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
'filter' => ''
|
||||
],
|
||||
[
|
||||
'name' => '_APP_MIGRATIONS_FIREBASE_CLIENT_SECRET',
|
||||
'description' => 'Google OAuth client secret. You can generate secrets in your GCP application settings.',
|
||||
'introduction' => '1.4.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
'filter' => ''
|
||||
]
|
||||
]
|
||||
],
|
||||
|
@ -1040,6 +1048,10 @@ return [
|
|||
'name' => '_APP_ASSISTANT_OPENAI_API_KEY',
|
||||
'description' => 'OpenAI API key. You can find it in your OpenAI application settings.',
|
||||
'introduction' => '1.4.0',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'question' => '',
|
||||
'filter' => ''
|
||||
]
|
||||
]
|
||||
]
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8ced2e82dd1cba2c2790c6562211b36f44198d89
|
||||
Subproject commit 51aa80cc80e83a41466bb353ccdff0e0e37d492f
|
|
@ -378,10 +378,6 @@ services:
|
|||
- _APP_DB_SCHEMA
|
||||
- _APP_DB_USER
|
||||
- _APP_DB_PASS
|
||||
- _APP_REDIS_HOST
|
||||
- _APP_REDIS_PORT
|
||||
- _APP_REDIS_USER
|
||||
- _APP_REDIS_PASS
|
||||
- _APP_LOGGING_PROVIDER
|
||||
- _APP_LOGGING_CONFIG
|
||||
- _APP_VCS_GITHUB_APP_NAME
|
||||
|
|
|
@ -6,7 +6,9 @@ use Appwrite\Auth\Auth;
|
|||
use Appwrite\Docker\Compose;
|
||||
use Appwrite\Docker\Env;
|
||||
use Appwrite\Utopia\View;
|
||||
use Utopia\Analytics\GoogleAnalytics;
|
||||
use Utopia\Analytics\Adapter;
|
||||
use Utopia\Analytics\Adapter\GoogleAnalytics;
|
||||
use Utopia\Analytics\Event;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Validator\Text;
|
||||
|
@ -33,22 +35,6 @@ class Install extends Action
|
|||
|
||||
public function action(string $httpPort, string $httpsPort, string $organization, string $image, string $interactive): void
|
||||
{
|
||||
/**
|
||||
* 1. Start - DONE
|
||||
* 2. Check for older setup and get older version - DONE
|
||||
* 2.1 If older version is equal or bigger(?) than current version, **stop setup**
|
||||
* 2.2. Get ENV vars - DONE
|
||||
* 2.2.1 Fetch from older docker-compose.yml file
|
||||
* 2.2.2 Fetch from older .env file (manually parse)
|
||||
* 2.3 Use old ENV vars as default values
|
||||
* 2.4 Ask for all required vars not given as CLI args and if in interactive mode
|
||||
* Otherwise, just use default vars. - DONE
|
||||
* 3. Ask user to backup important volumes, env vars, and SQL tables
|
||||
* In th future we can try and automate this for smaller/medium size setups
|
||||
* 4. Drop new docker-compose.yml setup (located inside the container, no network dependencies with appwrite.io) - DONE
|
||||
* 5. Run docker compose up -d - DONE
|
||||
* 6. Run data migration
|
||||
*/
|
||||
$config = Config::getParam('variables');
|
||||
$path = '/usr/src/code/appwrite';
|
||||
$defaultHTTPPort = '80';
|
||||
|
@ -70,7 +56,7 @@ class Install extends Action
|
|||
Console::success('Starting Appwrite installation...');
|
||||
|
||||
// Create directory with write permissions
|
||||
if (null !== $path && !\file_exists(\dirname($path))) {
|
||||
if (!\file_exists(\dirname($path))) {
|
||||
if (!@\mkdir(\dirname($path), 0755, true)) {
|
||||
Console::error('Can\'t create directory ' . \dirname($path));
|
||||
Console::exit(1);
|
||||
|
@ -198,31 +184,28 @@ class Install extends Action
|
|||
}
|
||||
}
|
||||
|
||||
$templateForCompose = new View(__DIR__ . '/../views/install/compose.phtml');
|
||||
$templateForEnv = new View(__DIR__ . '/../views/install/env.phtml');
|
||||
$templateForCompose = new View(__DIR__ . '/../../../../app/views/install/compose.phtml');
|
||||
$templateForEnv = new View(__DIR__ . '/../../../../app/views/install/env.phtml');
|
||||
|
||||
$templateForCompose
|
||||
->setParam('httpPort', $httpPort)
|
||||
->setParam('httpsPort', $httpsPort)
|
||||
->setParam('version', APP_VERSION_STABLE)
|
||||
->setParam('organization', $organization)
|
||||
->setParam('image', $image)
|
||||
;
|
||||
->setParam('image', $image);
|
||||
|
||||
$templateForEnv
|
||||
->setParam('vars', $input)
|
||||
;
|
||||
$templateForEnv->setParam('vars', $input);
|
||||
|
||||
if (!file_put_contents($path . '/docker-compose.yml', $templateForCompose->render(false))) {
|
||||
$message = 'Failed to save Docker Compose file';
|
||||
$analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message);
|
||||
$this->sendEvent($analytics, $message);
|
||||
Console::error($message);
|
||||
Console::exit(1);
|
||||
}
|
||||
|
||||
if (!file_put_contents($path . '/.env', $templateForEnv->render(false))) {
|
||||
$message = 'Failed to save environment variables file';
|
||||
$analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message);
|
||||
$this->sendEvent($analytics, $message);
|
||||
Console::error($message);
|
||||
Console::exit(1);
|
||||
}
|
||||
|
@ -243,14 +226,29 @@ class Install extends Action
|
|||
|
||||
if ($exit !== 0) {
|
||||
$message = 'Failed to install Appwrite dockers';
|
||||
$analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message);
|
||||
$this->sendEvent($analytics, $message);
|
||||
Console::error($message);
|
||||
Console::error($stderr);
|
||||
Console::exit($exit);
|
||||
} else {
|
||||
$message = 'Appwrite installed successfully';
|
||||
$analytics->createEvent('install/server', 'install', APP_VERSION_STABLE . ' - ' . $message);
|
||||
$this->sendEvent($analytics, $message);
|
||||
Console::success($message);
|
||||
}
|
||||
}
|
||||
|
||||
private function sendEvent(Adapter $analytics, string $message): void
|
||||
{
|
||||
$event = new Event();
|
||||
$event->setName(APP_VERSION_STABLE);
|
||||
$event->setValue($message);
|
||||
$event->setUrl('http://localhost/');
|
||||
$event->setProps([
|
||||
'category' => 'install/server',
|
||||
'action' => 'install',
|
||||
]);
|
||||
$event->setType('install/server');
|
||||
|
||||
$analytics->createEvent($event);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue