69 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			YAML
		
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			YAML
		
	
	
| kind: pipeline
 | ||
| type: docker
 | ||
| name: deployment
 | ||
| 
 | ||
| steps:
 | ||
|   - name: check
 | ||
|     image: alpine
 | ||
|     commands:
 | ||
|       - ls -la
 | ||
|       - ls -la Dockerfile # 查看当前文件夹是否包含了Dockerfile
 | ||
|   - name: publish
 | ||
|     image: plugins/docker
 | ||
|     settings:
 | ||
|       username:
 | ||
|         from_secret: nexus_username
 | ||
|       password:
 | ||
|         from_secret: nexus_password
 | ||
|       pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
 | ||
|       dockerfile: Dockerfile
 | ||
|       tags: latest
 | ||
|       # you need insecure: true since we don't have a TLS certificate
 | ||
|       insecure: true
 | ||
|       registry: 192.168.31.104:8082
 | ||
|       repo: 192.168.31.104:8082/tiamo/user-point-management
 | ||
|     volumes: # 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
 | ||
|       - name: dockersock
 | ||
|         path: /var/run/docker.sock
 | ||
|   - name: deploy
 | ||
|     pull: if-not-exists
 | ||
|     image: appleboy/drone-ssh
 | ||
|     environment:
 | ||
|       Connection:
 | ||
|         from_secret: connection
 | ||
|       NEXUS_USER:
 | ||
|         from_secret: nexus_username
 | ||
|       NEXUS_PASSWORD:
 | ||
|         from_secret: nexus_password
 | ||
|     settings:
 | ||
|       host: 192.168.31.225
 | ||
|       port: 22
 | ||
|       username: drone
 | ||
|       password: dronepw
 | ||
|       command_timeout: 2m
 | ||
|       envs: [ NEXUS_USER, NEXUS_PASSWORD ]
 | ||
|       script:
 | ||
|         - echo $NEXUS_PASSWORD | docker login -u $NEXUS_USER --password-stdin 192.168.31.104:8082
 | ||
|         - docker pull 192.168.31.104:8082/tiamo/user-point-management
 | ||
|         - echo 开始停止容器
 | ||
|         - docker stop user-point-management
 | ||
|         - echo 开始强制清除停止容器
 | ||
|         - docker container prune -f
 | ||
|         - echo 开始清除镜像
 | ||
|         - docker image prune -f 
 | ||
|         - echo 开始标签镜像
 | ||
|         - docker tag 192.168.31.104:8082/tiamo/user-point-management tiamo/user-point-management:latest
 | ||
|         - echo 开始运行容器
 | ||
|         - docker run --name user-point-management -d -p 29029:5000 
 | ||
|           -e Connection__UserPointManagement="Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;" 
 | ||
|           tiamo/user-point-management
 | ||
|         - echo 执行完成
 | ||
| 
 | ||
| volumes:
 | ||
|   - name: dockersock
 | ||
|     host:
 | ||
|       path: /var/run/docker.sock
 | ||
| 
 | ||
| #trigger:
 | ||
| #  branch:
 | ||
| #    - master |