kind: pipeline type: docker name: short-url-fastapi steps: # 部署 - name: deploy-clean image: appleboy/drone-ssh when: branch: master event: push settings: host: from_secret: ssh_host username: from_secret: ssh_username password: from_secret: ssh_password port: 22 command_timeout: 2m script: - cd /home/ubuntu/Projects/short_url_fastapi - | if sudo docker ps -f name=surl | grep -q surl; then sudo docker stop surl else echo "Container surl is not running, nothing to stop" fi - | if sudo docker ps -af name=surl | grep -q surl; then sudo docker rm surl else echo "Container surl does not exist, nothing to remove." fi - sudo docker rmi surl --force - sudo docker image prune -f - git pull --rebase - sudo docker build -t surl . - sudo docker run -d --name surl -p 8000:8000 -e docs=true surl