DOCKER_IMAGE_NAME=observe-ui
DOCKER_REMOTE_IMAGE_NAME=reg.cestong.com.cn/cecf/${DOCKER_IMAGE_NAME}
# DOCKER_REMOTE_IMAGE_NAME=pujielan/${DOCKER_IMAGE_NAME}

docker-build:
	npm run build
	git rev-parse --short HEAD > dist/version
	docker build . -t ${DOCKER_IMAGE_NAME}


docker-push: docker-build
	docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME}
	docker push ${DOCKER_REMOTE_IMAGE_NAME}


deploy: docker-push
	ssh km1 'kubectl rollout restart deployment obui -n observe'


docker-build-php:
	docker build -t registry.cestong.com:8150/zhixueyun/hx-php-server -f ./deploy/php/Dockerfile .

docker-push-php: docker-build-php
	docker push registry.cestong.com:8150/zhixueyun/hx-php-server

docker-build-nginx:
	docker build -t registry.cestong.com:8150/zhixueyun/hx-nginx -f ./deploy/nginx/Dockerfile .

db-backup-file = ~/data/test_ctc_backup_$(shell date '+%Y-%m-%dT%H-%M').sql
db-backup-test:
	ssh cest-2 'cd data && mysqldump -h 172.17.172.137 -u root -p1qaz2wsx3edc -P 53306 --databases ctc > dump.sql'
	scp cest-2:~/data/dump.sql ${db-backup-file}

db-sync-to-local: db-backup-test
	mysql -u root -p1234 -h 127.0.0.1 < ${db-backup-file}

release-tag:
	git tag "v${VERSION}"
	git push --tags

ob-pack:
	git rev-parse --short HEAD > version
	docker build -f buildDockerfile . -t ${DOCKER_IMAGE_NAME}
ob-push: ob-pack
	docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME}
	docker push ${DOCKER_REMOTE_IMAGE_NAME}

