forked from Lan2Play/eventula-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·410 lines (334 loc) · 16 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# Run local dev
start-local-dev: env-file-dev app-build-clean-dev interactive
switch-database: purge-containers dev-database wait database-import stop interactive
dev:
docker-compose -f docker-compose-dev.yml up -d --build
dev-local:
docker-compose -f docker-compose-dev.local.yml up -d --build
dev-database:
docker-compose -f docker-compose-dev.yml up -d eventula_manager_database
dev-database-local:
docker-compose -f docker-compose-dev.local.yml up -d eventula_manager_database
# Debug
interactive:
docker-compose -f docker-compose-dev.yml up
interactive-local:
docker-compose -f docker-compose-dev.local.yml up
# Stop all Containers
stop:
docker-compose -f docker-compose-dev.yml stop
stop-local:
docker-compose -f docker-compose-dev.local.yml stop
# Build from clean
app-build-clean: folder-structure-prd layout-images-prd app-build-dep generate-key-prd dev wait database-migrate database-seed stop
app-build-clean-local: folder-structure-prd layout-images-prd app-build-dep generate-key-prd dev-local wait database-migrate database-seed stop-local
# Build dev from clean
app-build-clean-dev: folder-structure-dev layout-images-dev app-build-dep-dev purge-cache generate-key-dev dev wait database-migrate database-seed stop
app-build-clean-local-dev: folder-structure-dev layout-images-dev app-build-dep-dev purge-cache generate-key-dev dev-local wait database-migrate database-seed stop-local
# Build Dependencies
app-build-dep: composer-install npm-install mix
# Build Dev App & Dependencies
app-build-dep-dev: composer-install-dev npm-install-dev mix-dev
# Make Documentation
docs-html:
docker run --rm -v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/docs:/docs lan2play/docker-sphinxbuild:latest
###########
# HELPERS #
###########
# Make .env
logs:
docker-compose logs -f
# Make .env
env-file-dev:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))):/localdir \
--user $(shell id -u):$(shell id -g) php:8-fpm-alpine /bin/sh -c " \
[ ! -f /localdir/src/.env ] && cp /localdir/.env.example /localdir/src/.env && sed -i \"s|UUID=82|UUID=$(shell id -u)|g\" /localdir/src/.env && sed -i \"s|GUID=82|GUID=$(shell id -g)|g\" /localdir/src/.env; exit 0"
# Make .env
env-file-prd:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))):/localdir \
--user 82:82 php:8-fpm-alpine /bin/sh -c " \
[ ! -f /localdir/src/.env ] && cp /localdir/.env.example /localdir/src/.env; exit 0"
# Make blank .env
env-file-blank:
touch src/.env
# echo "APP_KEY=" >> src/.env
# Move default images to Storage
layout-images-prd:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user 82:82 php:8-fpm-alpine /bin/sh -c " \
cp -r /app/resources/assets/images/* /app/storage/app/public/images/main/ && \
mv /app/storage/app/public/images/main/shop/* /app/storage/app/public/images/shop/"
# Move default images to Storage
layout-images-dev:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) php:8-fpm-alpine /bin/sh -c " \
cp -r /app/resources/assets/images/* /app/storage/app/public/images/main/ && \
mv /app/storage/app/public/images/main/shop/* /app/storage/app/public/images/shop/"
# Create Symlink for Storage
symlink:
docker exec eventula_manager_app php artisan storage:link
# Create & Update the Database
database-migrate:
docker exec eventula_manager_app php artisan migrate
# recreate & update the Database
database-migrate-refresh:
docker exec eventula_manager_app php artisan migrate:refresh
# Seed the Database
database-seed:
docker exec eventula_manager_app php artisan db:seed
# Rollback last Database Migration
database-rollback:
docker exec eventula_manager_app php artisan migrate:rollback
# show newly generated Application Key
generate-key-show-newkey:
docker run --rm composer /bin/bash -c "echo 'generating key..' && composer create-project laravel/laravel example-app >/dev/null 2>/dev/null && cd example-app && php artisan key:generate >/dev/null 2>/dev/null && cat .env | grep APP_KEY=b"
# Generate Application key
generate-key-prd:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user 82:82 -e DB_CONNECTION=sqlite php:8-fpm-alpine /bin/sh -c "touch /app/database/database.sqlite; cd /app && php artisan key:generate; rm -rf /app/database/database.sqlite"
# Generate Application key
generate-key-dev:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) -e DB_CONNECTION=sqlite php:8-fpm-alpine /bin/sh -c "touch /app/database/database.sqlite; cd /app && php artisan key:generate; rm -rf /app/database/database.sqlite"
# Generate Settings - This will erase your current settings!
generate-settings:
docker exec eventula_manager_app php artisan db:seed --class=SettingsTableSeeder
# Generate Appearance - This will erase your current settings!
generate-appearance:
docker exec eventula_manager_app php artisan db:seed --class=AppearanceTableSeeder
# Generate Images - This will erase your current settings!
generate-images:
docker exec eventula_manager_app php artisan db:seed --class=SliderImageTableSeeder
# Generate testusers - This will spam 50 testuser to the Database!
generate-testuser:
docker exec eventula_manager_app php artisan db:seed --class=TestUserSeeder
# Generate requireddatabase - This will erase your current settings!
generate-requireddatabase:
docker exec eventula_manager_app php artisan db:seed --class=RequiredDatabaseSeeder --force
# execute command make command command=sqlcommandhere
command:
docker exec eventula_manager_app $(command)
# clear views
clear-views:
docker exec eventula_manager_app php artisan view:clear
# clear cache
clear-cache:
docker exec eventula_manager_app php artisan cache:clear
# Create Default Folder structure
folder-structure-prd:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/src \
--user 82:82 php:8-fpm-alpine /bin/sh -c " \
mkdir -p /src/storage/app/public/images/gallery/ && \
mkdir -p /src/storage/app/public/images/events/ && \
mkdir -p /src/storage/app/public/images/venues/ && \
mkdir -p /src/storage/app/public/images/main/ && \
mkdir -p /src/storage/app/public/images/shop/ && \
mkdir -p /src/storage/app/public/attachments/help/ "
folder-structure-dev:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/src \
--user $(shell id -u):$(shell id -g) php:8-fpm-alpine /bin/sh -c " \
mkdir -p /src/storage/app/public/images/gallery/ && \
mkdir -p /src/storage/app/public/images/events/ && \
mkdir -p /src/storage/app/public/images/venues/ && \
mkdir -p /src/storage/app/public/images/main/ && \
mkdir -p /src/storage/app/public/images/shop/ && \
mkdir -p /src/storage/app/public/attachments/help/ "
# Create SSL Keypair for Development
ssh-keygen:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout resources/certs/eventula_manager.key -out resources/certs/eventula_manager.crt
# Install PHP Dependencies via Composer
composer-install:
docker run --rm --name compose-maintainence --interactive \
--volume $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user 82:82 \
composer install --ignore-platform-reqs --no-scripts
# Install Dev PHP Dependencies via Composer
composer-install-dev:
docker run --rm --name compose-maintainence-dev --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) \
composer install --ignore-platform-reqs --no-scripts --dev
# Update Dev PHP Dependencies via Composer
composer-update:
docker run --rm --name compose-maintainence-update --interactive \
--volume $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) \
composer update --ignore-platform-reqs --no-scripts
# list Composer outdated
composer-outdated:
docker run --rm --name compose-maintainence-update --interactive \
--volume $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) \
composer outdated
# add PHP Dependencies via Composer - usage make composer-add-dep module=module/namehere
composer-add-dep:
docker run --rm --name compose-maintainence-update --interactive \
--volume $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) \
composer require $(module) --ignore-platform-reqs --no-scripts
# add Dev PHP Dependencies via Composer - usage make composer-add-dep module=module/namehere
composer-add-dep-dev:
docker run --rm --name compose-maintainence-update --interactive \
--volume $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/app \
--user $(shell id -u):$(shell id -g) \
composer require $(module) --ignore-platform-reqs --no-scripts --dev
# Install JS Dependencies via NPM
npm-install:
docker run --rm --name js-maintainence --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user 82:82 \
node:14.20 /bin/bash -ci "npm install --no-audit && npm run production"
# Install JS Dependencies via NPM
npm-install-gh:
docker run --rm --name js-maintainence --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user 0 \
node:14.20 /bin/bash -ci "npm install --no-audit && npm run production && chown -R $(shell id -u):$(shell id -g) /usr/src/app"
# Install Dev JS Dependencies via NPM
npm-install-dev:
docker run --rm --name js-maintainence-dev --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm install --no-audit && npm run dev"
#list npm package - usage make npm-ls module=module
npm-ls:
docker run --rm --name js-maintainence-list --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm ls $(module)"
#update npm packages - usage make npm-update
npm-update:
docker run --rm --name js-maintainence-list --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm update"
#audit npm packages - usage make npm-audit
npm-audit:
docker run --rm --name js-maintainence-list --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm audit"
#audit fix npm packages - usage make npm-audit-fix
npm-audit-fix:
docker run --rm --name js-maintainence-list --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm audit fix"
#list outdated npm packages
npm-outdated:
docker run --rm --name js-maintainence-outdated --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm outdated"
#rebuild node
npm-rebuild:
docker run --rm --name js-maintainence-outdated --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm rebuild"
# npm mix Runner
mix:
docker run --rm --name js-maintainence-dev --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user 82:82 \
node:14.20 /bin/bash -ci "npm run production"
mix-dev:
docker run --rm --name js-maintainence-dev --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/usr/src/app \
-w /usr/src/app \
--user $(shell id -u):$(shell id -g) \
node:14.20 /bin/bash -ci "npm run development"
# Purge Containers
purge-containers:
docker-compose -f docker-compose-dev.yml -p eventula_manager stop || true
docker-compose -f docker-compose-dev.yml -p eventula_manager rm -vf || true
docker rm eventula_manager_app || true
docker rm eventula_manager_database || true
docker volume rm eventula_manager_database || true
# Purge Caches
purge-cache:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/src \
--user $(shell id -u):$(shell id -g) php:8-fpm-alpine /bin/sh -c " \
rm -rf /src/storage/framework/cache/* && \
rm -rf /src/storage/framework/views/* && \
rm -rf /src/storage/framework/sessions/* && \
rm -rf /src/bootstrap/cache/* && \
rm -rf /src/storage/debugbar/* "
# Purge Caches
purge-files:
docker run --rm --name compkeygen --interactive \
-v $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/src:/src \
--user $(shell id -u):$(shell id -g) php:8-fpm-alpine /bin/sh -c " \
rm -rf /src/vendor/ ; \
rm -rf /src/node_modules/ ; \
rm -rf /src/public/css/* ; \
rm -rf /src/storage/app/public/images/gallery ; \
rm -rf /src/storage/app/public/images/events ; \
rm -rf /src/storage/app/public/images/venues ; \
rm -rf /src/storage/app/public/images/main ; \
rm -rf /src/storage/logs/* ; \
rm -rf /src/public/storage || true"
# execute mysql upgrade after upgrading db container usage make database-upgrade sqlrootpw=rootpasswordhere
database-upgrade:
docker exec -i eventula_manager_database /bin/bash -c 'mysql_upgrade -uroot -p$(sqlrootpw)'
# execute mysql command usage make database-command command=sqlcommandhere
database-command:
echo "use eventula_manager_database; $(command)" | docker exec -i eventula_manager_database mysql -u eventula_manager -p'password'
# import mysql database usage make database-command dbfile=dbfile.sql
ifndef dbfile
override dbfile = dbfile.sql
endif
database-import:
docker exec -i eventula_manager_database mysql -u eventula_manager -p'password' eventula_manager_database < $(dbfile)
# drops the database
database-drop:
echo "DROP DATABASE eventula_manager_database;" | docker exec -i eventula_manager_database mysql -u eventula_manager -p'password'
# creates the database
database-create:
echo "CREATE DATABASE eventula_manager_database;" | docker exec -i eventula_manager_database mysql -u eventula_manager -p'password'
# creates the database
database-renew: database-drop database-create database-migrate database-seed generate-requireddatabase
#show foreign keys usage make database-show-foreign table=tablename
database-show-foreign:
echo "SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = 'eventula_manager_database' AND REFERENCED_TABLE_NAME = '$(table)';" | docker exec -i eventula_manager_database mysql -u eventula_manager -p'password'
# get @lang from blade usage make get-blade-lang blade=pathtoblade prefix=langprefix
get-lang-blade:
cat $(blade) | grep -o "'$(prefix)\..*'" | sed "s|'||g" | sort | uniq | sed "s|.*\.|'|g" | sed -e "s/$$/' => '',/"
# set installed in database
set-installed:
make database-command command="update settings set value=1 where setting='installed';"
# set not installed in database
set-not-installed:
make database-command command="update settings set value=0 where setting='installed';"
# Wait for containers to initialize
wait:
sleep 30
###############
# DANGER ZONE #
###############
# Clean ALL! DANGEROUS!
purge-all:
echo 'This is dangerous!'
echo 'This will totally remove all data and information stored in your app!'
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
make purge-all-force
purge-all-force: stop purge-containers purge-cache purge-files