DOCKER_TEMP_DIR=temp

all: frontend backend

frontend:
	cd moneymgr_web && npm run build && cd ..
	rm -rf moneymgr_backend/static
	mv moneymgr_web/dist moneymgr_backend/static

backend: frontend
	cd moneymgr_backend && cargo clippy -- -D warnings && cargo build --release

backend_docker: backend
	rm -rf $(DOCKER_TEMP_DIR)
	mkdir $(DOCKER_TEMP_DIR)
	cp moneymgr_backend/target/release/moneymgr_backend $(DOCKER_TEMP_DIR)
	docker build -t pierre42100/moneymgr_backend -f moneymgr_backend/docker/moneymgr_backend/Dockerfile "$(DOCKER_TEMP_DIR)"
	rm -rf $(DOCKER_TEMP_DIR)
