DOCKER_TEMP_DIR=temp

all: frontend backend

frontend:
	cd remote_frontend && npm run build && cd ..
	rm -rf remote_backend/static
	mv remote_frontend/dist remote_backend/static

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

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