task: add repository task swarm deploy
This commit is contained in:
parent
dcf30657c1
commit
82906eb832
@ -19,8 +19,8 @@ func NewBuildDockerImageSubTask(cfg *configs.Config) *BuildDockerImageSubTask {
|
||||
func (task *BuildDockerImageSubTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
yarn build
|
||||
docker build -t "portainerci/portainer:ee4803" -f build/linux/Dockerfile .
|
||||
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v "/var/run/docker.sock:/var/run/docker.sock" -v ${env:HOME}/volume/portainer-ee-data-2:/data --add-host=host.docker.internal:host-gateway portainerci/portainer:ee4803
|
||||
docker build -t "portainerci/portainer-ee:4803" -f build/linux/Dockerfile .
|
||||
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v "/var/run/docker.sock:/var/run/docker.sock" -v ${env:HOME}/volume/portainer-ee-data-2:/data --add-host=host.docker.internal:host-gateway portainerci/portainer:ee-4803
|
||||
`)
|
||||
|
||||
return nil
|
||||
|
@ -18,6 +18,7 @@ func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
|
||||
func (task *MenuSubTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
NewBuildDockerImageSubTask(task.Config),
|
||||
NewSwarmDeploySubTask(task.Config),
|
||||
}
|
||||
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
67
go/repositories/portainer-ee/swarm_deploy.go
Normal file
67
go/repositories/portainer-ee/swarm_deploy.go
Normal file
@ -0,0 +1,67 @@
|
||||
package portaineree
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type SwarmDeploySubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewSwarmDeploySubTask(cfg *configs.Config) *SwarmDeploySubTask {
|
||||
return &SwarmDeploySubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *SwarmDeploySubTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
version: '3.2'
|
||||
|
||||
services:
|
||||
agent:
|
||||
image: portainer/agent:latest
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /var/lib/docker/volumes:/var/lib/docker/volumes
|
||||
networks:
|
||||
- agent_network
|
||||
deploy:
|
||||
mode: global
|
||||
placement:
|
||||
constraints: [node.platform.os == linux]
|
||||
|
||||
portainer:
|
||||
image: portainerci/portainer-ee:4803
|
||||
command: -H tcp://tasks.agent:9001 --tlsskipverify --log-level ERROR
|
||||
ports:
|
||||
- "9443:9443"
|
||||
- "9000:9000"
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /home/oscar/volume/portainer-ee-data-1:/data
|
||||
networks:
|
||||
- agent_network
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
|
||||
networks:
|
||||
agent_network:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
--------------------------
|
||||
docker stack deploy -c docker-compose.yaml portainer
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *SwarmDeploySubTask) String() string {
|
||||
return "Build Docker Image"
|
||||
}
|
Loading…
Reference in New Issue
Block a user