task: add docker image related tasks for different repositories

This commit is contained in:
oscarzhou 2023-01-09 12:05:32 +13:00
parent f7b2fcb5bd
commit 3c28c8cdd9
7 changed files with 185 additions and 1 deletions

View File

@ -17,7 +17,7 @@ func main() {
// Init tasks // Init tasks
taskItems := []common.Tasker{ taskItems := []common.Tasker{
tasks.NewListRepositoriesTask(config), tasks.NewListRepositoryMenuTask(config),
tasks.NewGenerateJwtTokenTask(config), tasks.NewGenerateJwtTokenTask(config),
tasks.NewCurlLookupTask(), tasks.NewCurlLookupTask(),
tasks.NewCodeSecurityScanTask(), tasks.NewCodeSecurityScanTask(),

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

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

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

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

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

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