task: add docker image related tasks for different repositories
This commit is contained in:
parent
f7b2fcb5bd
commit
3c28c8cdd9
@ -17,7 +17,7 @@ func main() {
|
||||
|
||||
// Init tasks
|
||||
taskItems := []common.Tasker{
|
||||
tasks.NewListRepositoriesTask(config),
|
||||
tasks.NewListRepositoryMenuTask(config),
|
||||
tasks.NewGenerateJwtTokenTask(config),
|
||||
tasks.NewCurlLookupTask(),
|
||||
tasks.NewCodeSecurityScanTask(),
|
||||
|
30
go/repositories/agent/build_docker_image.go
Normal file
30
go/repositories/agent/build_docker_image.go
Normal file
@ -0,0 +1,30 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type BuildDockerImageSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewBuildDockerImageSubTask(cfg *configs.Config) *BuildDockerImageSubTask {
|
||||
return &BuildDockerImageSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *BuildDockerImageSubTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
./dev.sh compile
|
||||
./dev.sh build
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *BuildDockerImageSubTask) String() string {
|
||||
return "Build Docker Image"
|
||||
}
|
31
go/repositories/agent/menu.go
Normal file
31
go/repositories/agent/menu.go
Normal file
@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
)
|
||||
|
||||
type MenuSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
|
||||
return &MenuSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
NewBuildDockerImageSubTask(task.Config),
|
||||
NewPushImageSubTask(task.Config),
|
||||
}
|
||||
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) String() string {
|
||||
return "agent"
|
||||
}
|
32
go/repositories/agent/push_image.go
Normal file
32
go/repositories/agent/push_image.go
Normal file
@ -0,0 +1,32 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type PushImageSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewPushImageSubTask(cfg *configs.Config) *PushImageSubTask {
|
||||
return &PushImageSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *PushImageSubTask) Execute() error {
|
||||
utils.SuccessPrint(`
|
||||
export CR_PAT=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
|
||||
echo $CR_PAT | docker login ghcr.io -u oscarzhou-portainer --password-stdin
|
||||
docker image tag portainerci/agent:develop-78af729 ghcr.io/oscarzhou-portainer/agent:develop-78af729
|
||||
docker push ghcr.io/oscarzhou-portainer/agent:develop-78af729docker
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *PushImageSubTask) String() string {
|
||||
return "Push Docker Image"
|
||||
}
|
31
go/repositories/portainer-ee/build_docker_image.go
Normal file
31
go/repositories/portainer-ee/build_docker_image.go
Normal file
@ -0,0 +1,31 @@
|
||||
package portaineree
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
"ocl/portainer-devtool/utils"
|
||||
)
|
||||
|
||||
type BuildDockerImageSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewBuildDockerImageSubTask(cfg *configs.Config) *BuildDockerImageSubTask {
|
||||
return &BuildDockerImageSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
`)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *BuildDockerImageSubTask) String() string {
|
||||
return "Build Docker Image"
|
||||
}
|
30
go/repositories/portainer-ee/menu.go
Normal file
30
go/repositories/portainer-ee/menu.go
Normal file
@ -0,0 +1,30 @@
|
||||
package portaineree
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
)
|
||||
|
||||
type MenuSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
|
||||
return &MenuSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
NewBuildDockerImageSubTask(task.Config),
|
||||
}
|
||||
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) String() string {
|
||||
return "portainer-ee"
|
||||
}
|
30
go/repositories/unpacker/menu.go
Normal file
30
go/repositories/unpacker/menu.go
Normal file
@ -0,0 +1,30 @@
|
||||
package unpacker
|
||||
|
||||
import (
|
||||
"ocl/portainer-devtool/configs"
|
||||
"ocl/portainer-devtool/tasks/common"
|
||||
)
|
||||
|
||||
type MenuSubTask struct {
|
||||
common.GeneralTask
|
||||
}
|
||||
|
||||
func NewMenuSubTask(cfg *configs.Config) *MenuSubTask {
|
||||
return &MenuSubTask{
|
||||
GeneralTask: *common.NewGeneralTask(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) Execute() error {
|
||||
subTaskItems := []common.Tasker{
|
||||
NewBuildDockerImageSubTask(task.Config),
|
||||
}
|
||||
|
||||
common.ListCommandMenu(subTaskItems, "Which management commands do you want to choose:", false, task.ParentTasks)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (task *MenuSubTask) String() string {
|
||||
return "unpacker"
|
||||
}
|
Loading…
Reference in New Issue
Block a user