-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcastor.php
66 lines (55 loc) · 1.97 KB
/
castor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use Castor\Attribute\AsTask;
use function Castor\import;
use function Castor\io;
use function Castor\notify;
use function docker\about;
use function docker\build;
use function docker\docker_compose_exec;
use function docker\docker_compose_run;
use function docker\generate_certificates;
use function docker\up;
import(__DIR__ . '/.castor');
/**
* @return array<string, string>
*/
function create_default_variables(): array
{
return [
'project_name' => 'observability',
'root_domain' => 'observability.test',
];
}
#[AsTask(description: 'Builds and starts the infrastructure, then install the application (composer, yarn, ...)')]
function start(): void
{
generate_certificates(force: false);
build();
up();
cache_clear();
install();
migrate();
notify('The stack is now up and running.');
io()->success('The stack is now up and running.');
about();
}
#[AsTask(description: 'Installs the application (composer, yarn, ...)', namespace: 'app', aliases: ['install'])]
function install(): void
{
docker_compose_run('composer install -n --prefer-dist --optimize-autoloader');
qa\install();
}
#[AsTask(description: 'Clear the application cache', namespace: 'app', aliases: ['cache-clear'])]
function cache_clear(): void
{
docker_compose_run('rm -rf var/cache/ && bin/console cache:warmup');
}
#[AsTask(description: 'Migrates database schema', namespace: 'app:db', aliases: ['migrate'])]
function migrate(): void
{
docker_compose_run('bin/console doctrine:database:create --if-not-exists');
docker_compose_run('bin/console doctrine:migration:migrate -n --allow-no-migration');
docker_compose_exec('bin/docker-entrypoint create_db', service: 'redash');
docker_compose_exec('clickhouse-client -q "CREATE DATABASE IF NOT EXISTS app"', service: 'clickhouse');
docker_compose_exec('clickhouse-client -q "CREATE TABLE IF NOT EXISTS app.logs (message String) ENGINE = MergeTree() ORDER BY tuple()"', service: 'clickhouse');
}