-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
145 lines (110 loc) · 6.52 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
include .env
start:
docker-compose up -d
start-prod:
docker-compose -f docker-compose.yml -f docker-compose-prod.yml up -d
stop:
@docker-compose down -v
restart:
@docker-compose down -v
docker-compose up -d
restart-prod:
@docker-compose down -v
docker-compose -f docker-compose.yml -f docker-compose-prod.yml up -d
ps:
docker-compose ps
logs:
@docker-compose logs -f
# Creates a database that the user specifies the name of
# Creates a database that the user specifies the name of
# Call via "make create-mariadb db=cabbage"
create-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
docker exec -i mariadb mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} -e "create database ${db};"
# Imports the specified database
# Call via "make import db=board"
import:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
docker exec -i mariadb mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} < etc/board.sql
# Creates a database export of the specified database and saves to the output directory specified in the .env file. Good for utilizing as a crontab.
# Call via "make backup-mariadb db=cabbage"
backup-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
mkdir -p $(MYSQL_DUMPS_DIR)
chmod -R 777 $(MYSQL_DUMPS_DIR)
docker exec mariadb mysqldump -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db} --single-transaction --quick --lock-tables=false | zip > $(MYSQL_DUMPS_DIR)/`date "+%Y%m%d-%H%M-%Z"`-${db}.zip
# Unzips a database backup zip file in the output directory specified in the .env file and then imports it into the specified database as a database restoration from backup method
# Call via "make restore-mariadb name=20191017-0226-EDT-cabbage.zip db=cabbage"
restore-mariadb:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
unzip -p $(MYSQL_DUMPS_DIR)/${name} | docker exec -i mariadb mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} ${db}
# Deletes database backup zip files odler than the number of days specified. Good for utilizing as a crontab.
# Call via "clear-backups days=90"
clear-backups:
@[ "${days}" ] || ( echo ">> days is not set"; exit 1 )
find $(MYSQL_DUMPS_DIR)/*.zip -mtime +${days} -exec rm -f {} \;
# Truncates database log tables that account for backup size bloat on heavy bot worlds
# Call via "truncate db=uranium"
truncate:
@[ "${db}" ] || ( echo ">> db is not set"; exit 1 )
docker exec -i mariadb mysql -u${MARIADB_ROOT_USER} -p${MARIADB_ROOT_PASSWORD} -e "USE ${db}; TRUNCATE generic_logs; TRUNCATE droplogs; TRUNCATE chat_logs; TRUNCATE logins; TRUNCATE trade_logs;"
# Installs any missing pieces for Laravel and updates everything needed to operate
update-laravel:
docker exec -i php bash -c "cd /var/www/html/portal && composer install && composer update && composer dump-autoload && php artisan key:generate && php artisan optimize && npm install && npm update && npm audit fix"
docker exec -i php bash -c "mkdir /opt/gpg"; docker cp /opt/gpg/openrsc-gpg-public-key-2023-02-16.key php:/opt/gpg/openrsc-gpg-public-key-2023-02-16.key; docker cp /opt/gpg/openrsc-gpg-private-key-2023-02-16.key php:/opt/gpg/openrsc-gpg-private-key-2023-02-16.key; docker exec -i php bash -c "mkdir /var/www/.gnupg; chown -R www-data:www-data /var/www/.gnupg";
# Alias of update-laravel
upgrade-laravel:
docker exec -i php bash -c "cd /var/www/html/portal && composer install && composer update && composer dump-autoload && php artisan key:generate && php artisan optimize && npm install && npm update && npm audit fix"
docker exec -i php bash -c "mkdir /opt/gpg"; docker cp /opt/gpg/openrsc-gpg-public-key-2023-02-16.key php:/opt/gpg/openrsc-gpg-public-key-2023-02-16.key; docker cp /opt/gpg/openrsc-gpg-private-key-2023-02-16.key php:/opt/gpg/openrsc-gpg-private-key-2023-02-16.key; docker exec -i php bash -c "mkdir /var/www/.gnupg; chown -R www-data:www-data /var/www/.gnupg";
# Clears the cache and routes used by Laravel
clear-all-laravel:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan view:clear && php artisan route:clear && php artisan config:cache && php artisan livewire:discover"
# Runs default database insert migrations
migrate-laravel:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan migrate --seed"
controller:
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
docker exec -i php bash -c "cd /var/www/html/portal && php artisan make:controller ${name}"
list-route:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan route:list"
clear-views:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan view:clear"
clear-route:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan route:clear"
migrate:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan migrate"
migrate-refresh:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan migrate:refresh"
publish-pagination:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan vendor:publish --tag=laravel-pagination"
version:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan --version"
npm-install:
docker exec -i php bash -c "cd /var/www/html/portal && npm install"
npm-run-dev:
docker exec -i php bash -c "cd /var/www/html/portal && npm run development"
npm-run-prod:
docker exec -i php bash -c "cd /var/www/html/portal && npm run production"
npm-run-watch:
docker exec -i php bash -c "cd /var/www/html/portal && npm run watch"
npm-audit-fix:
docker exec -it php bash -c "cd /var/www/html/portal && npm update && npm install & npm audit fix --force"
livewire-discover:
docker exec -i php bash -c "cd /var/www/html/portal && php artisan livewire:discover"
livewire:
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
docker exec -i php bash -c "cd /var/www/html/portal && php artisan livewire:make ${name}"
# Usage: make generate-model name=phpbb_topics
generate-model:
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
docker exec -i php bash -c "cd /var/www/html/portal && php artisan krlove:generate:model ${name} --table-name ${name}"
# Generates passport keys
generate-passport:
docker exec -it php bash -c "cd /var/www/html/portal && php artisan passport:keys --force"
# Creates a new tagged image in Docker Hub for the named container
# Usage: make docker-push name=openrsc/php
docker-push:
@[ "${name}" ] || ( echo ">> name is not set"; exit 1 )
docker tag php ${name}
docker push ${name}