input: Write a python function to ssh into an EC2 instance, update the packages, install Docker and Docker Compose, clone a git repository, build a Docker image, migrate the database, and run a Django server.
  assert deploy_django_app('<KeyPair>.pem', '<EC2_Public_IP>', '<Git_Repo_URL>') == "Deployment successful"
  assert deploy_django_app('mykey.pem', '192.168.1.1', 'https://github.com/example/repo.git') == "Deployment successful"
  assert deploy_django_app('keyfile.pem', '10.0.0.1', 'https://github.com/sample/project.git') == "Deployment successful"
output: def deploy_django_app(key_pair, ec2_ip, git_repo_url):
      import paramiko
      import time
  
      def ssh_connect(ip, key_file):
          ssh = paramiko.SSHClient()
          ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
          ssh.connect(ip, username='ec2-user', key_filename=key_file)
          return ssh
  
      def run_command(ssh, command):
          stdin, stdout, stderr = ssh.exec_command(command)
          stdout.channel.recv_exit_status()
          return stdout.read().decode(), stderr.read().decode()
  
      ssh = ssh_connect(ec2_ip, key_pair)
  
      # Update packages
      run_command(ssh, 'sudo yum update -y')
  
      # Install Docker
      run_command(ssh, 'sudo amazon-linux-extras install docker -y')
      run_command(ssh, 'sudo service docker start')
      run_command(ssh, 'sudo usermod -a -G docker ec2-user')
  
      # Install Docker Compose
      run_command(ssh, 'sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose')
      run_command(ssh, 'sudo chmod +x /usr/local/bin/docker-compose')
  
      # Clone the git repository
      run_command(ssh, f'git clone {git_repo_url} app')
      run_command(ssh, 'cd app')
  
      # Build Docker image
      run_command(ssh, 'sudo docker-compose build')
  
      # Migrate the database
      run_command(ssh, 'sudo docker-compose run web python manage.py migrate')
  
      # Run the Django server
      run_command(ssh, 'sudo docker-compose up -d')
  
      ssh.close()
      return "Deployment successful"