ci(drone): Enhance Docker configuration and deployment pipeline
	
		
			
	
		
	
	
		
	
		
			Some checks reported errors
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build encountered an error
				
			
		
		
	
	
				
					
				
			
		
			Some checks reported errors
		
		
	
	continuous-integration/drone/push Build encountered an error
				
			- Added Docker-in-Docker (dind) service for improved containerization - Configured Docker registry mirror for faster image pulls - Updated deployment step to include Docker daemon configuration - Added volume mounting for Docker socket across build and deploy stages - Simplified and optimized Docker-related configuration in .drone.yml
This commit is contained in:
		
							parent
							
								
									29a51d37c8
								
							
						
					
					
						commit
						c95584d7fc
					
				
							
								
								
									
										29
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								.drone.yml
									
									
									
									
									
								
							@ -1,6 +1,6 @@
 | 
				
			|||||||
kind: pipeline
 | 
					kind: pipeline
 | 
				
			||||||
type: docker
 | 
					type: docker
 | 
				
			||||||
name: nodejs-deploy
 | 
					name: automated-api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
volumes:
 | 
					volumes:
 | 
				
			||||||
  - name: node_modules
 | 
					  - name: node_modules
 | 
				
			||||||
@ -15,15 +15,10 @@ steps:
 | 
				
			|||||||
    image: plugins/docker
 | 
					    image: plugins/docker
 | 
				
			||||||
    settings:
 | 
					    settings:
 | 
				
			||||||
      dockerfile: Dockerfile
 | 
					      dockerfile: Dockerfile
 | 
				
			||||||
      repo: your-registry/nodejs-app
 | 
					      repo: automated-api
 | 
				
			||||||
      tags:
 | 
					      tags:
 | 
				
			||||||
        - latest
 | 
					        - latest
 | 
				
			||||||
        - ${DRONE_COMMIT_SHA:0:8}
 | 
					        - ${DRONE_COMMIT_SHA:0:8}
 | 
				
			||||||
      registry: registry.cn-hangzhou.aliyuncs.com  # 替换为您的镜像仓库地址
 | 
					 | 
				
			||||||
      username:
 | 
					 | 
				
			||||||
        from_secret: docker_username
 | 
					 | 
				
			||||||
      password:
 | 
					 | 
				
			||||||
        from_secret: docker_password
 | 
					 | 
				
			||||||
    volumes:
 | 
					    volumes:
 | 
				
			||||||
      - name: node_modules
 | 
					      - name: node_modules
 | 
				
			||||||
        path: /drone/src/node_modules
 | 
					        path: /drone/src/node_modules
 | 
				
			||||||
@ -31,20 +26,30 @@ steps:
 | 
				
			|||||||
        path: /root/.local/share/pnpm/store
 | 
					        path: /root/.local/share/pnpm/store
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: deploy
 | 
					  - name: deploy
 | 
				
			||||||
    image: docker
 | 
					 | 
				
			||||||
    commands:
 | 
					    commands:
 | 
				
			||||||
      - docker stop nodejs-app || true
 | 
					      # 配置多个 Docker 镜像加速源
 | 
				
			||||||
      - docker rm nodejs-app || true
 | 
					      - mkdir -p /etc/docker
 | 
				
			||||||
 | 
					      - |
 | 
				
			||||||
 | 
					        echo '{
 | 
				
			||||||
 | 
					          "registry-mirrors": [
 | 
				
			||||||
 | 
					            "https://docker.1panel.live",
 | 
				
			||||||
 | 
					            "https://ustc-edu-cn.mirror.aliyuncs.com",
 | 
				
			||||||
 | 
					            "https://ccr.ccs.tencentyun.com",
 | 
				
			||||||
 | 
					            "https://docker.m.daocloud.io"
 | 
				
			||||||
 | 
					          ]
 | 
				
			||||||
 | 
					        }' > /etc/docker/daemon.json
 | 
				
			||||||
 | 
					      - docker stop automated-api || true
 | 
				
			||||||
 | 
					      - docker rm automated-api || true
 | 
				
			||||||
      - >
 | 
					      - >
 | 
				
			||||||
        docker run -d
 | 
					        docker run -d
 | 
				
			||||||
        --name nodejs-app
 | 
					        --name automated-api
 | 
				
			||||||
        --restart always
 | 
					        --restart always
 | 
				
			||||||
        -p 8001:8001
 | 
					        -p 8001:8001
 | 
				
			||||||
        -v /usr/local/blackend/node_modules:/app/node_modules
 | 
					        -v /usr/local/blackend/node_modules:/app/node_modules
 | 
				
			||||||
        -v /usr/local/blackend/pnpm_cache:/root/.local/share/pnpm/store
 | 
					        -v /usr/local/blackend/pnpm_cache:/root/.local/share/pnpm/store
 | 
				
			||||||
        -e NODE_ENV=production
 | 
					        -e NODE_ENV=production
 | 
				
			||||||
        -e PORT=8001
 | 
					        -e PORT=8001
 | 
				
			||||||
        your-registry/nodejs-app:latest
 | 
					        automated-api:latest
 | 
				
			||||||
    volumes:
 | 
					    volumes:
 | 
				
			||||||
      - name: docker_sock
 | 
					      - name: docker_sock
 | 
				
			||||||
        path: /var/run/docker.sock
 | 
					        path: /var/run/docker.sock
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user