task: add portainer standalone deploy task

This commit is contained in:
oscarzhou 2023-01-13 14:08:59 +13:00
parent 82906eb832
commit 885098809b
6 changed files with 94 additions and 1 deletions

View File

@ -23,6 +23,7 @@ func main() {
tasks.NewTestEnvironmentTask(),
tasks.NewCurlLookupTask(),
tasks.NewCodeSecurityScanTask(),
tasks.NewInstallDockerTask(),
tasks.NewListDevToolCommandTask(config),
}

View File

@ -20,6 +20,9 @@ func (task *BuildDockerImageSubTask) Execute() error {
utils.SuccessPrint(`
./dev.sh compile
./dev.sh build
----
./dev.sh compile
docker build -t "portainerci/agent:oscar-alpine" -f build/linux/alpine.Dockerfile .
`)
return nil

View File

@ -19,6 +19,7 @@ func (task *MenuSubTask) Execute() error {
subTaskItems := []common.Tasker{
NewBuildDockerImageSubTask(task.Config),
NewSwarmDeploySubTask(task.Config),
NewStandaloneDeploySubTask(task.Config),
}
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)

View 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"
}

View File

@ -63,5 +63,5 @@ docker stack deploy -c docker-compose.yaml portainer
}
func (task *SwarmDeploySubTask) String() string {
return "Build Docker Image"
return "Deploy Portainer in Swarm"
}

View 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"
}