-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (75 loc) · 4.36 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
# This Makefile requires GNU Make.
MAKEFLAGS += --silent
# Settings
C_BLU='\033[0;34m'
C_GRN='\033[0;32m'
C_RED='\033[0;31m'
C_YEL='\033[0;33m'
C_END='\033[0m'
include .env
DOCKER_TITLE=$(PROJECT_TITLE)
CURRENT_DIR=$(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
DIR_BASENAME=$(shell basename $(CURRENT_DIR))
ROOT_DIR=$(CURRENT_DIR)
help: ## shows this Makefile help message
echo 'usage: make [target]'
echo
echo 'targets:'
egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'
# -------------------------------------------------------------------------------------------------
# System
# -------------------------------------------------------------------------------------------------
.PHONY: hostname fix-permission host-check
hostname: ## shows local machine ip
echo $(word 1,$(shell hostname -I))
echo $(ip addr show | grep "\binet\b.*\bdocker0\b" | awk '{print $2}' | cut -d '/' -f 1)
fix-permission: ## sets project directory permission
$(DOCKER_USER) chown -R ${USER}: $(ROOT_DIR)/
host-check: ## shows this project ports availability on local machine
cd docker/nginx-php && $(MAKE) port-check
# -------------------------------------------------------------------------------------------------
# Application Service
# -------------------------------------------------------------------------------------------------
.PHONY: prestashop-ssh prestashop-set prestashop-create prestashop-start prestashop-stop prestashop-destroy prestashop-install prestashop-update
prestashop-ssh: ## enters the application container shell
cd docker/nginx-php && $(MAKE) ssh
prestashop-set: ## sets the application PHP enviroment file to build the container
cd docker/nginx-php && $(MAKE) env-set
prestashop-create: ## creates the application PHP container from Docker image
cd docker/nginx-php && $(MAKE) env-set build up
prestashop-start: ## starts the application PHP container running
cd docker/nginx-php && $(MAKE) start
prestashop-stop: ## stops the application PHP container but data will not be destroyed
cd docker/nginx-php && $(MAKE) stop
prestashop-destroy: ## removes the application PHP from Docker network destroying its data and Docker image
cd docker/nginx-php && $(MAKE) clear destroy
prestashop-install: ## installs the application pre-defined version with its dependency packages into container
curl https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.11/prestashop_1.7.8.11.zip -O -J -L
prestashop-update: ## updates the application dependency packages into container
cd docker/nginx-php && $(MAKE) app-update
# -------------------------------------------------------------------------------------------------
# Prestashop Plugin
# -------------------------------------------------------------------------------------------------
.PHONY: plugin-zip
plugin-zip:
cd resources/plugin/dev && zip -r ../pr-custom.zip *
# -------------------------------------------------------------------------------------------------
# Database Container Service
# -------------------------------------------------------------------------------------------------
.PHONY: database-install database-replace database-backup
database-install: ## installs into container database the init sql file from resources/database
sudo docker exec -i $(DB_CAAS) sh -c 'exec mysql $(DB_NAME) -uroot -p"$(DB_ROOT)"' < $(DB_BACKUP_PATH)/$(DB_BACKUP_NAME)-init.sql
echo ${C_YEL}"DATABASE"${C_END}" has been installed."
database-replace: ## replaces container database with the latest sql backup file from resources/database
sudo docker exec -i $(DB_CAAS) sh -c 'exec mysql $(DB_NAME) -uroot -p"$(DB_ROOT)"' < $(DB_BACKUP_PATH)/$(DB_BACKUP_NAME)-backup.sql
echo ${C_YEL}"DATABASE"${C_END}" has been replaced."
database-backup: ## creates / replace a sql backup file from container database in resources/database
sudo docker exec $(DB_CAAS) sh -c 'exec mysqldump $(DB_NAME) -uroot -p"$(DB_ROOT)"' > $(DB_BACKUP_PATH)/$(DB_BACKUP_NAME)-backup.sql
echo ${C_YEL}"DATABASE"${C_END}" backup has been created."
# -------------------------------------------------------------------------------------------------
# Repository Helper
# -------------------------------------------------------------------------------------------------
repo-flush: ## clears local git repository cache specially to update .gitignore
git rm -rf --cached .
git add .
git commit -m "fix: cache cleared for untracked files"