task: add portainer standalone deploy task
This commit is contained in:
		
							parent
							
								
									82906eb832
								
							
						
					
					
						commit
						885098809b
					
				@ -23,6 +23,7 @@ func main() {
 | 
				
			|||||||
		tasks.NewTestEnvironmentTask(),
 | 
							tasks.NewTestEnvironmentTask(),
 | 
				
			||||||
		tasks.NewCurlLookupTask(),
 | 
							tasks.NewCurlLookupTask(),
 | 
				
			||||||
		tasks.NewCodeSecurityScanTask(),
 | 
							tasks.NewCodeSecurityScanTask(),
 | 
				
			||||||
 | 
							tasks.NewInstallDockerTask(),
 | 
				
			||||||
		tasks.NewListDevToolCommandTask(config),
 | 
							tasks.NewListDevToolCommandTask(config),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,9 @@ func (task *BuildDockerImageSubTask) Execute() error {
 | 
				
			|||||||
	utils.SuccessPrint(`
 | 
						utils.SuccessPrint(`
 | 
				
			||||||
./dev.sh compile
 | 
					./dev.sh compile
 | 
				
			||||||
./dev.sh build
 | 
					./dev.sh build
 | 
				
			||||||
 | 
					----
 | 
				
			||||||
 | 
					./dev.sh compile
 | 
				
			||||||
 | 
					docker build -t "portainerci/agent:oscar-alpine" -f build/linux/alpine.Dockerfile .
 | 
				
			||||||
	`)
 | 
						`)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 | 
				
			|||||||
@ -19,6 +19,7 @@ func (task *MenuSubTask) Execute() error {
 | 
				
			|||||||
	subTaskItems := []common.Tasker{
 | 
						subTaskItems := []common.Tasker{
 | 
				
			||||||
		NewBuildDockerImageSubTask(task.Config),
 | 
							NewBuildDockerImageSubTask(task.Config),
 | 
				
			||||||
		NewSwarmDeploySubTask(task.Config),
 | 
							NewSwarmDeploySubTask(task.Config),
 | 
				
			||||||
 | 
							NewStandaloneDeploySubTask(task.Config),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
 | 
						common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										32
									
								
								go/repositories/portainer-ee/standalone_deploy.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								go/repositories/portainer-ee/standalone_deploy.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package portaineree
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"ocl/portainer-devtool/configs"
 | 
				
			||||||
 | 
						"ocl/portainer-devtool/tasks/common"
 | 
				
			||||||
 | 
						"ocl/portainer-devtool/utils"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type StandaloneDeploySubTask struct {
 | 
				
			||||||
 | 
						common.GeneralTask
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewStandaloneDeploySubTask(cfg *configs.Config) *StandaloneDeploySubTask {
 | 
				
			||||||
 | 
						return &StandaloneDeploySubTask{
 | 
				
			||||||
 | 
							GeneralTask: *common.NewGeneralTask(cfg),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (task *StandaloneDeploySubTask) Execute() error {
 | 
				
			||||||
 | 
						utils.SuccessPrint(`
 | 
				
			||||||
 | 
					yarn build
 | 
				
			||||||
 | 
					docker build -t "portainerci/portainer-ee:oscar-test" -f build/linux/linux.Dockerfile .
 | 
				
			||||||
 | 
					docker image tag portainerci/portainer-ee:oscar-test portainerci/portainer-ee:latest
 | 
				
			||||||
 | 
					docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v "/var/run/docker.sock:/var/run/docker.sock" -v /home/oscar/volume/portainer-ee-data-1:/data --add-host=host.docker.internal:host-gateway portainerci/portainer-ee:oscar-test
 | 
				
			||||||
 | 
						`)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (task *StandaloneDeploySubTask) String() string {
 | 
				
			||||||
 | 
						return "Deploy Portainer in Docker Standalone"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -63,5 +63,5 @@ docker stack deploy -c docker-compose.yaml portainer
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (task *SwarmDeploySubTask) String() string {
 | 
					func (task *SwarmDeploySubTask) String() string {
 | 
				
			||||||
	return "Build Docker Image"
 | 
						return "Deploy Portainer in Swarm"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										56
									
								
								go/tasks/install_docker.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								go/tasks/install_docker.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					package tasks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"ocl/portainer-devtool/tasks/common"
 | 
				
			||||||
 | 
						"ocl/portainer-devtool/utils"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type InstallDockerTask struct {
 | 
				
			||||||
 | 
						ParentTasks []common.Tasker
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewInstallDockerTask() *InstallDockerTask {
 | 
				
			||||||
 | 
						return &InstallDockerTask{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (task *InstallDockerTask) Execute() error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						utils.SuccessPrint(`
 | 
				
			||||||
 | 
						sudo apt-get update
 | 
				
			||||||
 | 
						sudo apt-get install \
 | 
				
			||||||
 | 
							ca-certificates \
 | 
				
			||||||
 | 
							curl \
 | 
				
			||||||
 | 
							gnupg \
 | 
				
			||||||
 | 
							lsb-release
 | 
				
			||||||
 | 
						sudo mkdir -p /etc/apt/keyrings
 | 
				
			||||||
 | 
						curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
 | 
				
			||||||
 | 
						echo \
 | 
				
			||||||
 | 
					  		"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
 | 
				
			||||||
 | 
					 	$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
 | 
				
			||||||
 | 
						sudo apt-get update
 | 
				
			||||||
 | 
						sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
						sudo apt install docker.io
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
						sudo groupadd docker
 | 
				
			||||||
 | 
						sudo usermod -aG docker $USER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						multipass list
 | 
				
			||||||
 | 
						multipass shell <instance name>
 | 
				
			||||||
 | 
						sudo passwd ubuntu
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						newgrp docker
 | 
				
			||||||
 | 
						`)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (task *InstallDockerTask) SetParentTaskers(tasks []common.Tasker) {
 | 
				
			||||||
 | 
						task.ParentTasks = tasks
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (task *InstallDockerTask) String() string {
 | 
				
			||||||
 | 
						return "Install Docker Binary"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user