-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
executable file
·103 lines (87 loc) · 2.17 KB
/
fabfile.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from fabric.api import local
def docker_compose(command):
"""
Docker Compose
"""
local('docker-compose -f infrastructure/docker-compose.yml '+ command)
def logs(container = ''):
"""
Display infrastructure logs
"""
docker_compose('logs -f --tail=150 ' + container)
def ps():
"""
List containers
"""
docker_compose('ps')
def stop():
"""
Stop the infrastructure
"""
docker_compose('down')
def build():
"""
Build the infrastructure
"""
local('cp -n infrastructure/services/.env.dist infrastructure/services/.env')
docker_compose('build')
def php(command):
docker_compose('exec --user $(id -u):$(id -g) php ' + command)
def composer(command):
"""
Composer
"""
php('composer ' + command)
def up():
"""
Build and start the infrastructure
"""
build()
local('mkdir -p application/var')
docker_compose('up -d')
def create():
"""
Create
"""
composer('create-project symfony/website-skeleton app')
local('mv application/app/* application/app/.[^.]* application/.')
local('rm -R application/app > /dev/null 2>&1')
def configure():
"""
Configure the application
"""
local ('rm -f application/.env.local')
local('echo MAILER_DSN=smtp://mailcatcher:1025 >> application/.env.local')
local('echo DATABASE_URL=mysql://user:password@mysql:3306/database >> application/.env.local')
def start():
"""
Build and start the infrastructure, then install the application (composer, yarn, ...)
"""
up()
install()
fixtures()
def install():
"""
Install the application (composer, yarn, ...)
"""
composer('install -n --prefer-dist --optimize-autoloader')
def symfony(command):
php('php bin/console ' + command)
def migrate():
"""
Migrate database schema
"""
symfony('doctrine:database:create --if-not-exists')
symfony('doctrine:migration:migrate -n')
def fixtures():
"""
Generate fixtures
"""
symfony('doctrine:database:drop --force')
migrate()
# symfony('doctrine:fixtures:load -n')
def cache_clear():
"""
Clear the application cache
"""
symfony('cache:clear')