-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
32 lines (27 loc) · 1.06 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
help:
@echo "Usage: make [command]"
@echo ""
@echo "help – Show this help"
@echo "up – Start the mysql container locally"
@echo "down – Stop the mysql container"
@echo "dump – Dump to the local '.sql' file"
@echo "mysql – Connect to local MySQL server with a shell"
@echo "rollback – Rollback to local '.sql' file"
up:
docker compose up --build --detach
down:
docker compose down
dump:
docker compose exec -T mysql mysqldump --user=root --password=secret \
--lock-all-tables --default-character-set=utf8mb4 \
--databases serlo > docker-entrypoint-initdb.d/001-init.sql
mysql:
docker compose exec -it mysql serlo-mysql
rollback:
docker compose cp docker-entrypoint-initdb.d/001-init.sql \
mysql:/docker-entrypoint-initdb.d/001-init.sql
docker compose exec -it mysql mysql \
--user=root --password=secret -e \
"DROP DATABASE IF EXISTS serlo; CREATE DATABASE serlo CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
docker compose exec mysql \
sh -c "pv /docker-entrypoint-initdb.d/001-init.sql | serlo-mysql"