50 lines
1.3 KiB
Makefile
50 lines
1.3 KiB
Makefile
DOCKER ?= docker
|
|
COMPOSE ?= docker compose
|
|
PUBLIC_URL ?= https://askar.abbiamoundominio.org
|
|
TMPDB_CONN = --host=127.0.0.1 --port=3307 --user=root --password=toor --ssl-verify-server-cert=FALSE
|
|
DUMP_CONN = -h 127.0.0.1 -P 3306 --user root --password=toor --ssl-verify-server-cert=FALSE
|
|
VERSIONED_DUMP = ./assets/db/dump.sql
|
|
TMP_PROD_DUMP = ./out/db.tmp.sql
|
|
PROD_DUMP = ./out/dump.sql
|
|
|
|
dev-run:
|
|
$(COMPOSE) up
|
|
|
|
dev-stop:
|
|
$(COMPOSE) down
|
|
|
|
dev-clean:
|
|
$(COMPOSE) down --volumes
|
|
|
|
dev-dump:
|
|
mariadb-dump $(DUMP_CONN) askar > $(VERSIONED_DUMP)
|
|
|
|
./out:
|
|
mkdir ./out
|
|
|
|
prepare: ./out prepare-image prepare-db
|
|
|
|
prepare-image:
|
|
$(DOCKER) build -t unit/askar-website .
|
|
$(DOCKER) image save -o out/image.tar unit/askar-website
|
|
|
|
tmpdb-start:
|
|
$(DOCKER) run -d --rm --name tmpdb \
|
|
-p 3307:3306 \
|
|
-e MYSQL_DATABASE=askar \
|
|
-e MYSQL_USER=askar \
|
|
-e MYSQL_PASSWORD=askar \
|
|
-e MYSQL_ROOT_PASSWORD=toor \
|
|
mysql:8
|
|
while ! mariadb-admin ping $(TMPDB_CONN); do sleep 1; done
|
|
|
|
tmpdb-stop:
|
|
$(DOCKER) stop tmpdb
|
|
|
|
tmpdb-do-dump:
|
|
cat $(VERSIONED_DUMP) | sed -e 's;http://localhost:8080;$(PUBLIC_URL);g' > $(TMP_PROD_DUMP)
|
|
cat $(TMP_PROD_DUMP) | grep -v -E '^/\*' | (echo "SET sql_mode = '';" && cat) | mariadb $(TMPDB_CONN) askar
|
|
mariadb-dump --default-character-set=binary --hex-blob $(TMPDB_CONN) askar | grep -v -E '^/\*' > $(PROD_DUMP)
|
|
|
|
prepare-db: tmpdb-start tmpdb-do-dump tmpdb-stop
|