initial commit

This commit is contained in:
2021-10-21 02:51:32 +02:00
commit d9c1c42150
30 changed files with 1617 additions and 0 deletions

22
app/cmd/docker/build.go Normal file
View File

@ -0,0 +1,22 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeBuild = cli.Command{
Name: "pull",
Usage: "build docker image",
Description: `Build all docker images`,
Action: RunComposeBuild,
}
func RunComposeBuild(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerBuild(ctx)
return nil
}

21
app/cmd/docker/debug.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeDebug = cli.Command{
Name: "debug",
Usage: "debug main container",
Description: `Run shell on main container without entrypoint execute`,
Action: RunComposeDebug,
}
func RunComposeDebug(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerDebug(ctx)
return nil
}

21
app/cmd/docker/down.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeDown = cli.Command{
Name: "down",
Usage: "down all containers",
Description: `Down all containers defined in docker-compose`,
Action: RunComposeDown,
}
func RunComposeDown(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerDown(ctx)
return nil
}

22
app/cmd/docker/fqn.go Normal file
View File

@ -0,0 +1,22 @@
package docker
import (
"fmt"
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdDockerFqn = cli.Command{
Name: "fqn",
Aliases: []string{"f"},
Usage: "Docker image fqn",
Description: `Get fqn docker image defined as main service in config file`,
Action: RunDockerFqn,
}
func RunDockerFqn(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
fmt.Printf("%v", compose.ShowDockerImageFQN(ctx))
return nil
}

22
app/cmd/docker/logs.go Normal file
View File

@ -0,0 +1,22 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeLogs = cli.Command{
Name: "logs",
Aliases: []string{"l"},
Usage: "logs from containers",
Description: `Get fqn docker image defined as main service in config file`,
Action: RunComposeLogs,
}
func RunComposeLogs(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerLogs(ctx)
return nil
}

21
app/cmd/docker/ps.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdDockerPs = cli.Command{
Name: "ps",
Aliases: []string{"p"},
Usage: "list running containers",
Description: `List all containers defined in docker-compose use in current mode`,
Action: RunComposePs,
}
func RunComposePs(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerPs(ctx)
return nil
}

21
app/cmd/docker/pull.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposePull = cli.Command{
Name: "pull",
Usage: "docker image pull",
Description: `Pull docker image from registry server`,
Action: RunComposePull,
}
func RunComposePull(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerPull(ctx)
return nil
}

21
app/cmd/docker/restart.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeRestart = cli.Command{
Name: "restart",
Usage: "Restart containers",
Description: `Restart all containers defined in docker-compose`,
Action: RunComposeRestart,
}
func RunComposeRestart(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerRestart(ctx)
return nil
}

21
app/cmd/docker/run.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeRun = cli.Command{
Name: "run",
Usage: "run cmd in main container",
Description: `Run command in main container`,
Action: RunComposeRun,
}
func RunComposeRun(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerRun(ctx)
return nil
}

21
app/cmd/docker/shell.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeShell = cli.Command{
Name: "shell",
Usage: "run shell from main service",
Description: `Execute shell cmd in main service`,
Action: RunComposeShell,
}
func RunComposeShell(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerShell(ctx)
return nil
}

20
app/cmd/docker/start.go Normal file
View File

@ -0,0 +1,20 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeStart = cli.Command{
Name: "start",
Usage: "start containers",
Description: `Start all containers defined in docker-compose stack run mode`,
Action: RunComposeStart,
}
func RunComposeStart(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerStart(ctx)
return nil
}

22
app/cmd/docker/stop.go Normal file
View File

@ -0,0 +1,22 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeStop = cli.Command{
Name: "stop",
Usage: "stop containers",
Description: `Stop all containers defined in docker-compose stack mode`,
Action: RunComposePull,
}
func RunComposeStop(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerStop(ctx)
return nil
}

22
app/cmd/docker/up.go Normal file
View File

@ -0,0 +1,22 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdDockerUp = cli.Command{
Name: "up",
Aliases: []string{"u"},
Usage: "up containers",
Description: `Up all containers defined in docker-compose use in current mode`,
Action: RunComposeUp,
}
func RunComposeUp(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerUp(ctx)
return nil
}

21
app/cmd/docker/uponce.go Normal file
View File

@ -0,0 +1,21 @@
package docker
import (
"github.com/urfave/cli/v2"
"ledo/app/modules/compose"
"ledo/app/modules/context"
)
var CmdComposeUpOnce = cli.Command{
Name: "uponce",
Usage: "up one container",
Description: `Up one container from docker compose stack`,
Action: RunComposeUpOnce,
}
func RunComposeUpOnce(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
compose.ExecComposerUpOnce(ctx)
return nil
}