Rewrite bin/deploy to support local and remote apps