-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
111 lines (81 loc) · 2.88 KB
/
Makefile
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
104
105
106
107
108
109
110
111
.PHONY:build
include .env
# Container management
######################
up:
docker compose up -d
up_mysql:
mkdir -p tmp/db
docker compose up -d mysql
up_app:
docker compose up -d app
down:
docker compose down
reup: down up
logs:
docker compose logs -f
build:
docker compose build --no-cache
make up
make composer_install
make db_mysql_create_database
make app_database_migrate
make exec_app_cmd CMD="php bin/console.php storage:link"
# Container interaction
#######################
exec_app_bash:
docker compose exec app bash
exec_app_cmd:
docker compose exec app bash -c "${CMD}"
exec_mysql_cli:
docker compose exec mysql sh -c "mysql -u${DB_USER} -p${DB_PASSWORD} ${DATABASE_MYSQL_NAME}"
exec_mysql_query:
docker compose exec mysql bash -c "mysql -uroot -p${DATABASE_MYSQL_ROOT_PASSWORD} -e \"$(QUERY)\""
# Composer
##########
composer_install:
make exec_app_cmd CMD="composer install"
composer_update:
make exec_app_cmd CMD="composer update"
composer_test:
make exec_app_cmd CMD="composer test"
# Database
##########
db_mysql_create_database:
make exec_mysql_query QUERY="CREATE DATABASE IF NOT EXISTS $(DATABASE_MYSQL_NAME)"
make exec_mysql_query QUERY="GRANT ALL PRIVILEGES ON $(DATABASE_MYSQL_NAME).* TO $(DATABASE_MYSQL_USER)@'%'"
make exec_mysql_query QUERY="FLUSH PRIVILEGES;"
make app_database_migrate
db_mysql_import:
docker cp storage/dump.sql movary-mysql-1:/tmp/dump.sql
docker compose exec mysql bash -c 'mysql -uroot -p${DATABASE_MYSQL_ROOT_PASSWORD} movary < /tmp/dump.sql'
db_mysql_export:
docker compose exec mysql bash -c 'mysqldump --databases --add-drop-database -uroot -p$(DATABASE_MYSQL_ROOT_PASSWORD) $(DATABASE_MYSQL_NAME) > /tmp/dump.sql'
docker cp movary-mysql-1:/tmp/dump.sql storage/dump.sql
chown $(USER_ID):$(USER_ID) storage/dump.sql
db_migration_create:
make exec_app_cmd CMD="vendor/bin/phinx create Migration -c ./settings/phinx.php"
# App commands
##############
app_sync_all: app_sync_trakt app_sync_tmdb
app_database_migrate:
make exec_app_cmd CMD="php bin/console.php database:migration:migrate "
app_database_rollback:
make exec_app_cmd CMD="php bin/console.php database:migration:rollback"
app_user_create_test:
make exec_app_cmd CMD="php bin/console.php user:create [email protected] password123 testUser"
app_user_change_password_test:
make exec_app_cmd CMD="php bin/console.php user:update 1 --password=password123"
app_user_import_trakt:
make exec_app_cmd CMD="php bin/console.php trakt:import --overwrite --userId=1"
app_tmdb_sync_movie:
make exec_app_cmd CMD="php bin/console.php tmdb:movie:sync --threshold=100"
app_tmdb_sync_person:
make exec_app_cmd CMD="php bin/console.php tmdb:movie:sync --threshold=100"
app_imdb_sync_rating:
make exec_app_cmd CMD="php bin/console.php imdb:sync --threshold=1"
app_jobs_process:
make exec_app_cmd CMD="php bin/console.php jobs:process"
# Shortcuts
php: exec_app_bash
test: composer_test