docker_deploy:

	docker run --rm -it \
	  -v /tmp/backup:/backup -v /var/lib/docker:/docker \
		-v $(shell pwd)/kit:/docker/volumes/web-wordpress-kit_wordpress/_data/wp-content/themes/kit \
		alpine:edge tar cpfz /backup/volumes.tgz /docker/volumes/
	rsync --progress /tmp/backup/volumes.tgz playground.pi:/tmp/

	-DOCKER_HOST="ssh://playground.pi" docker stop web-wordpress-kit_db_1 web-wordpress-kit_wordpress_1
	-DOCKER_HOST="ssh://playground.pi" docker rm web-wordpress-kit_db_1 web-wordpress-kit_wordpress_1
	-DOCKER_HOST="ssh://playground.pi" docker volume rm web-wordpress-kit_db web-wordpress-kit_wordpress

	DOCKER_HOST="ssh://playground.pi" docker run --rm -it \
	  -v /var/lib/docker:/docker \
		-v /tmp:/volume-backup \
		alpine:edge tar --strip-components=2 -xpvf /volume-backup/volumes.tgz -C /docker/volumes/
	DOCKER_HOST="ssh://playground.pi" docker run --rm -it \
	  -v /var/lib/docker:/docker \
		-v /tmp:/volume-backup \
		alpine:edge sed -i 81idefine\\\(\\\'WP_SITEURL\\\',\\\'https://beta.saai.digital\\\'\\\)\\\;\\ndefine\\\(\\\'WP_HOME\\\',\\\'https://beta.saai.digital\\\'\\\)\\\; /docker/volumes/web-wordpress-kit_wordpress/_data/wp-config.php

	# # Need to fix MaxSessions in remote ssh daemon https://github.com/docker/compose/issues/6463
	# # Disable nftables on remote host

	cp wordpress.yml /tmp/wordpress.yml
	sed -e '/kit/ s/^#*/#/' -i /tmp/wordpress.yml
	DOCKER_HOST="ssh://playground.pi" docker-compose -p web-wordpress-kit -f /tmp/wordpress.yml create
	DOCKER_HOST="ssh://playground.pi" docker-compose -p web-wordpress-kit -f /tmp/wordpress.yml start

docker_up:
	docker-compose -f wordpress.yml up

generate_pot:
	wp i18n make-pot kit kit/languages/kit.pot # generate source file
	for i18n in "de_DE" "fr_FR"; do \
	   # update translated language file \
		msgmerge -N kit/languages/$${i18n}.po kit/languages/kit.pot > kit/languages/$${i18n}.po.new ; \
		mv kit/languages/$${i18n}.po.new kit/languages/$${i18n}.po ;\
		# generate mo file \
		msgfmt -o kit/languages/$${i18n}.mo kit/languages/$${i18n}.po ; \
	done
