Skip to content

Commit e4bfc72

Browse files
committed
devops-config: added some needs
1 parent 3e08774 commit e4bfc72

16 files changed

+377
-0
lines changed

Makefile

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
SHELL=/bin/bash
2+
3+
include .env
4+
export $(shell sed 's/=.*//' .env)
5+
6+
# MySQL
7+
MYSQL_DUMPS_DIR=data/db/dumps
8+
9+
help:
10+
@echo ""
11+
@echo "usage: make COMMAND"
12+
@echo ""
13+
@echo "Commands:"
14+
@echo " init Gives permissions to scripts need it"
15+
@echo " copy-env Copy .env.example to .env"
16+
@echo " update-env-example Copy .env keys to .env.example"
17+
@echo " composer-download Install composer on docker"
18+
@echo " composer-install Install composer dependencies"
19+
@echo " composer-up Update PHP dependencies with composer"
20+
@echo " composer-dump-autoload Recreating autoload"
21+
@echo " php-bash 🐘 Bash al contenedor php"
22+
@echo " php-psysh 🐘 Shell interactiva de PHP"
23+
@echo " mysql-bash Bash al contenedor MySQL"
24+
@echo " nginx-bash Bash al contenedor NGIX"
25+
@echo " redis-bash Bash al contenedor Redis"
26+
@echo " start 🏎 💨 Starts all Docker containers from docker-compose.yml"
27+
@echo " stop 🛑 Stops all Docker containers from docker-compose.yml"
28+
@echo " logs 📜 Shows the logs of the docker containers"
29+
@echo " clear-cache 🧽 Clears cache"
30+
@echo " clear-views 🧽 Clears cache from the views"
31+
@echo " clear-config 🧽 Clears cache from config files"
32+
@echo " clear-all-cache 🧽 Clears all the caches"
33+
@echo " generate-key 🔑 Generate key for Laravel app"
34+
@echo " migrate Migraciones"
35+
@echo " passport-key 🔑 Passport keys"
36+
@echo " mysql-cli MySQL CLI‍"
37+
@echo " logs 💾 Follow log output"
38+
@echo " mysql-dump 🗃 Create backup of all databases"
39+
@echo " mysql-restore 🗃 Restore backup of all databases"
40+
@echo " test 💯 Test PHP application"
41+
@echo " horizon-install Horizon install"
42+
43+
init:
44+
@chmod +x ./docker-artisan.sh
45+
@chmod +x ./docker.sh
46+
47+
update-env-example:
48+
@sed 's/=.*/=/' .env > .env.example
49+
50+
copy-env:
51+
@cp .env.example .env
52+
53+
composer-download:
54+
@echo "Installing dependencies ⬇️"
55+
@echo "--------------------------️"
56+
@./docker.sh exec php-fpm docker-php-ext-install curl
57+
@./docker.sh exec php-fpm docker-php-ext-install pcntl
58+
@./docker.sh exec php-fpm docker-php-ext-install exif
59+
@./docker.sh exec php-fpm apt-get update
60+
@./docker.sh exec php-fpm apt-get upgrade
61+
@echo "--------------------------️"
62+
@echo "Installing composer @ docker ⬇️"
63+
@echo "--------------------------️"
64+
@./docker.sh exec php-fpm curl -sS https://getcomposer.org/installer > composer-setup.php
65+
@./docker.sh exec php-fpm php composer-setup.php --install-dir=/usr/bin --filename=composer
66+
@./docker.sh exec php-fpm rm -rf composer-setup.php
67+
@make composer-faster
68+
@echo "--------------------------️"
69+
@echo " ⬇️ Installing prestissimo to make composer faster ⚡"
70+
@echo "--------------------------️"
71+
@./docker.sh exec php-fpm composer global require hirak/prestissimo
72+
@echo "--------------------------️"
73+
@echo "Installing composer dependencies ⬇️"
74+
@echo "--------------------------️"
75+
@./docker.sh exec php-fpm composer install
76+
@echo "--------------------------️"
77+
@echo "Cambiar propietario del directorio de las dependencias 🔐"
78+
@echo "--------------------------️"
79+
@chown $(USER):$(USER) -R vendor
80+
81+
composer-faster:
82+
@echo "--------------------------️"
83+
@echo " ⬇️ Installing prestissimo to make composer faster ⚡"
84+
@echo "--------------------------️"
85+
@./docker.sh exec php-fpm composer global require hirak/prestissimo
86+
87+
composer-install:
88+
@echo "--------------------------️"
89+
@echo "Installing composer dependencies ⬇️"
90+
@echo "--------------------------️"
91+
@./docker.sh exec php-fpm composer install
92+
@echo "--------------------------️"
93+
@echo "Cambiar propietario del directorio de las dependencias 🔐"
94+
@echo "--------------------------️"
95+
@chown $(USER):$(USER) -R vendor
96+
97+
composer-dump-autoload:
98+
@echo "--------------------------️"
99+
@echo "Recreating the autoload ♻️"
100+
@echo "--------------------------️"
101+
@./docker.sh exec php-fpm composer dump-autoload
102+
@echo "--------------------------️"
103+
@echo "Cambiar propietario del directorio de las dependencias 🔐"
104+
@echo "--------------------------️"
105+
@chown $(USER):$(USER) -R vendor
106+
107+
composer-up:
108+
@make nova-credentials
109+
@./docker.sh exec php-fpm composer update
110+
@echo "--------------------------️"
111+
@echo "Cambiar propietario del directorio de las dependencias 🔐"
112+
@echo "--------------------------️"
113+
@chown $(USER):$(USER) -R vendor
114+
115+
nova-credentials:
116+
@echo "--------------------------️"
117+
@echo " 🔐 NOVA credentials"
118+
@echo "--------------------------️"
119+
@echo "HORIZON_USER: $(HORIZON_USER)"
120+
@echo "NOVA_KEY: $(NOVA_KEY)"
121+
122+
php-bash:
123+
@./docker.sh exec php-fpm /bin/bash
124+
125+
php-psysh:
126+
@./docker.sh run --rm --entrypoint=vendor/bin/psysh php-fpm
127+
128+
mysql-bash:
129+
@./docker.sh exec mysql /bin/bash
130+
131+
nginx-bash:
132+
@./docker.sh exec nginx /bin/bash
133+
134+
redis-bash:
135+
@./docker.sh exec redis /bin/bash
136+
137+
start:
138+
@$(shell ./docker.sh up -d nginx mysql redis php-fpm)
139+
140+
stop:
141+
@$(shell ./docker.sh down -v)
142+
143+
logs:
144+
@./docker.sh logs -f
145+
146+
clear-cache:
147+
@./docker-artisan.sh cache:clear
148+
149+
clear-views:
150+
@./docker-artisan.sh view:clear
151+
152+
clear-config:
153+
@./docker-artisan.sh config:clear
154+
155+
clear-all-cache:
156+
@make clear-cache
157+
@make clear-views
158+
@make clear-config
159+
160+
generate-key:
161+
@./docker-artisan.sh key:generate
162+
163+
migrate:
164+
@./docker-artisan.sh migrate --seed
165+
166+
passport-key:
167+
@./docker-artisan.sh passport:keys
168+
169+
testing-db:
170+
@./docker-artisan.sh migrate --database=testing
171+
172+
mysql-cli:
173+
@./docker.sh exec mysql mysql -u$(DB_USERNAME) -p$(DB_USERNAME)
174+
175+
test:
176+
@./docker.sh run --rm --entrypoint=vendor/bin/phpunit php-fpm --colors=always
177+
178+
mysql-dump:
179+
@mkdir -p $(MYSQL_DUMPS_DIR)
180+
@./docker.sh exec mysql mysqldump --all-databases -u$(DB_USERNAME) -p$(DB_USERNAME) > $(MYSQL_DUMPS_DIR)/db.sql
181+
182+
mysql-restore:
183+
@./docker.sh exec mysql mysql -u$(DB_USERNAME) -p$(DB_PASSWORD) < $(MYSQL_DUMPS_DIR)/db.sql
184+
185+
horizon-install:
186+
@./docker-artisan.sh horizon:install
187+
188+
resert-owner:
189+
@sudo chown $(USER):$(USER) -R vendor
190+
@sudo chown $(USER):$(USER) -R build
191+
192+
.PHONY: test init

alter_table_user.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
MYSQL_USER=$(grep -w MYSQL_USER .env | cut -d '=' -f2)
4+
MYSQL_PASSWD=$(grep -w MYSQL_PASSWD .env | cut -d '=' -f2)
5+
MYSQL_MIGRATION=$(grep -w MYSQL_MIGRATION .env | cut -d '=' -f2)
6+
7+
echo "⚒ Creating Alter table to fix MySQL 8 probles with auth"
8+
echo "============================"
9+
echo "📑 Creating Alter table ${MYSQL_MIGRATION}/0_alter_user.sql"
10+
echo "ALTER USER '${MYSQL_USER}'@'%' IDENTIFIED WITH mysql_native_password BY '${MYSQL_PASSWD}';" > ${MYSQL_MIGRATION}/0_alter_user.sql;
11+
echo "flush privileges;" >>${MYSQL_MIGRATION}/0_alter_user.sql;

erase_docker_mysql_volume.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
# Getting .env values to use on the script
3+
CONTAINER_ID=$(grep MYSQL_SERVICE_NAME .env | cut -d '=' -f2)
4+
5+
docker-compose stop $CONTAINER_ID
6+
docker-compose rm -f $CONTAINER_ID
7+
sudo rm -rf data/db

generate_migrations.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
# Getting .env values to use on the script
3+
MYSQL_SCRIPT_DIR=$(grep -w MYSQL_SCRIPT_DIR .env | cut -d '=' -f2)
4+
MYSQL_MIGRATION=$(grep -w MYSQL_MIGRATION .env | cut -d '=' -f2)
5+
6+
find $MYSQL_MIGRATION -type f -name "*.sql" | sort -n -k2 | xargs cat > ${MYSQL_SCRIPT_DIR}/migrations.sql

mysql_client.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
CONTAINER_ID=$(grep -w MYSQL_HOST .env | cut -d '=' -f2)
3+
MYSQL_USER=$(grep -w MYSQL_USER .env | cut -d '=' -f2)
4+
MYSQL_PASSWD=$(grep -w MYSQL_PASSWD .env | cut -d '=' -f2)
5+
MYSQL_DB=$(grep -w MYSQL_DB .env | cut -d '=' -f2)
6+
7+
8+
docker exec -it $CONTAINER_ID mysql -u${MYSQL_USER} -p${MYSQL_PASSWD} $MYSQL_DB

mysql_dump.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
# Getting .env values to use on the script
3+
CONTAINER_ID=$(grep -w MYSQL_SERVICE_NAME .env | cut -d '=' -f2)
4+
MYSQL_USER=$(grep -w MYSQL_USER .env | cut -d '=' -f2)
5+
MYSQL_PASSWD=$(grep -w MYSQL_PASSWD .env | cut -d '=' -f2)
6+
MYSQL_SCRIPT_PATH=$(grep -w MYSQL_SCRIPT_PATH .env | cut -d '=' -f2)
7+
8+
docker-compose exec -T ${CONTAINER_ID} mysqldump -e --all-databases -u${MYSQL_USER} -p${MYSQL_PASSWD} > ${MYSQL_SCRIPT_PATH}

mysql_migrations.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CONTAINER_ID=$(grep -w MYSQL_HOST .env | cut -d '=' -f2)
2+
MYSQL_USER=$(grep -w MYSQL_USER .env | cut -d '=' -f2)
3+
MYSQL_PASSWD=$(grep -w MYSQL_PASSWD .env | cut -d '=' -f2)
4+
MYSQL_DB=$(grep -w MYSQL_DB .env | cut -d '=' -f2)
5+
MYSQL_SCRIPT_PATH=$(grep -w MYSQL_SCRIPT_MIGRATIONS .env | cut -d '=' -f2)
6+
MYSQL_SCRIPT_DIR=$(grep -w MYSQL_SCRIPT_DIR .env | cut -d '=' -f2)
7+
8+
9+
echo "☢ Executing SQL migration"
10+
echo "============================"
11+
echo "📑 Copying sql file ${MYSQL_SCRIPT_PATH##*/} from $MYSQL_SCRIPT_PATH"
12+
13+
docker cp $MYSQL_SCRIPT_PATH $CONTAINER_ID:$MYSQL_SCRIPT_DIR
14+
echo "💾 Executing sql ${MYSQL_SCRIPT_PATH##*/}"
15+
docker exec -i $CONTAINER_ID mysql -u${MYSQL_USER} -p${MYSQL_PASSWD} $MYSQL_DB < $MYSQL_SCRIPT_PATH

mysql_restore.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
# Getting .env values to use on the script
3+
CONTAINER_ID=$(grep -w MYSQL_HOST .env | cut -d '=' -f2)
4+
MYSQL_USER=$(grep -w MYSQL_USER .env | cut -d '=' -f2)
5+
MYSQL_PASSWD=$(grep -w MYSQL_PASSWD .env | cut -d '=' -f2)
6+
MYSQL_DB=$(grep -w MYSQL_DB .env | cut -d '=' -f2)
7+
MYSQL_SCRIPT_PATH=$(grep -w MYSQL_SCRIPT_PATH .env | cut -d '=' -f2)
8+
MYSQL_SCRIPT_DIR=$(grep -w MYSQL_SCRIPT_DIR .env | cut -d '=' -f2)
9+
10+
11+
echo "☢ Executing SQL migration"
12+
echo "============================"
13+
echo "📑 Copying sql file ${MYSQL_SCRIPT_PATH##*/} from $MYSQL_SCRIPT_PATH"
14+
15+
docker cp $MYSQL_SCRIPT_PATH $CONTAINER_ID:$MYSQL_SCRIPT_DIR
16+
echo "💾 Executing sql ${MYSQL_SCRIPT_PATH##*/}"
17+
docker exec -i $CONTAINER_ID mysql -u${MYSQL_USER} -p${MYSQL_PASSWD} $MYSQL_DB < $MYSQL_SCRIPT_PATH

package.json.example

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "test-1",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"test:unit": "vue-cli-service test:unit",
9+
"test:e2e": "vue-cli-service test:e2e --headless",
10+
"lint": "vue-cli-service lint",
11+
"install": "./script/install.sh",
12+
"docker:lint": "./script/docker/lint.sh",
13+
"docker:serve": "docker-compose up -d",
14+
"docker:serve-monitoring": "docker-compose up -d && ./script/lazydocker.sh",
15+
"docker:serve-stop": "docker-compose stop",
16+
"docker:install": "./script/docker/install.sh",
17+
"docker:e2e": "./script/docker/e2e.sh --headless",
18+
"docker:unit": "./script/docker/unit.sh"
19+
},
20+
"dependencies": {
21+
"core-js": "^3.6.4",
22+
"register-service-worker": "^1.7.1",
23+
"vue": "^2.6.11",
24+
"vue-class-component": "^7.2.3",
25+
"vue-property-decorator": "^8.4.1",
26+
"vue-router": "^3.1.6",
27+
"vuex": "^3.1.3"
28+
},
29+
"devDependencies": {
30+
"@types/jest": "^24.0.19",
31+
"@typescript-eslint/eslint-plugin": "^2.26.0",
32+
"@typescript-eslint/parser": "^2.26.0",
33+
"@vue/cli-plugin-babel": "~4.3.0",
34+
"@vue/cli-plugin-e2e-cypress": "~4.3.0",
35+
"@vue/cli-plugin-eslint": "~4.3.0",
36+
"@vue/cli-plugin-pwa": "~4.3.0",
37+
"@vue/cli-plugin-router": "~4.3.0",
38+
"@vue/cli-plugin-typescript": "~4.3.0",
39+
"@vue/cli-plugin-unit-jest": "~4.3.0",
40+
"@vue/cli-plugin-vuex": "~4.3.0",
41+
"@vue/cli-service": "~4.3.0",
42+
"@vue/eslint-config-prettier": "^6.0.0",
43+
"@vue/eslint-config-typescript": "^5.0.2",
44+
"@vue/test-utils": "1.0.0-beta.31",
45+
"eslint": "^6.7.2",
46+
"eslint-plugin-prettier": "^3.1.1",
47+
"eslint-plugin-vue": "^6.2.2",
48+
"node-sass": "^4.12.0",
49+
"prettier": "^1.19.1",
50+
"sass-loader": "^8.0.2",
51+
"typescript": "~3.8.3",
52+
"vue-template-compiler": "^2.6.11"
53+
}
54+
}

script/docker/e2e.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# Getting .env values to use on the script
4+
CONTAINER_ID=$(grep NODE_CONTAINER_NAME .env | cut -d '=' -f2);
5+
6+
docker exec -it $CONTAINER_ID ./node_modules/.bin/cypress install;
7+
docker exec -it $CONTAINER_ID apt-get update && apt-get install -y libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 xvfb;
8+
docker exec -it $CONTAINER_ID ./node_modules/.bin/vue-cli-service test:e2e $@;
9+
10+
return 0;

0 commit comments

Comments
 (0)