image
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"ledo/app/cmd/docker"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/cmd/docker"
|
||||
)
|
||||
|
||||
var CmdDocker = cli.Command{
|
||||
@ -12,10 +11,8 @@ var CmdDocker = cli.Command{
|
||||
Category: catHelpers,
|
||||
Usage: "docker helper",
|
||||
Description: `Manage docker-compose in project`,
|
||||
Action: runDockerDefault,
|
||||
Subcommands: []*cli.Command{
|
||||
&docker.CmdDockerPs,
|
||||
&docker.CmdDockerFqn,
|
||||
&docker.CmdDockerUp,
|
||||
&docker.CmdComposeBuild,
|
||||
&docker.CmdComposeDebug,
|
||||
@ -31,7 +28,3 @@ var CmdDocker = cli.Command{
|
||||
&docker.CmdDockerLogin,
|
||||
},
|
||||
}
|
||||
|
||||
func runDockerDefault(ctx *cli.Context) error {
|
||||
return docker.RunComposePs(ctx)
|
||||
}
|
||||
|
23
app/cmd/image.go
Normal file
23
app/cmd/image.go
Normal file
@ -0,0 +1,23 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"ledo/app/cmd/image"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var CmdImage = cli.Command{
|
||||
Name: "image",
|
||||
Aliases: []string{"i"},
|
||||
Category: catHelpers,
|
||||
Usage: "docker container helper",
|
||||
Description: `docker container helper`,
|
||||
Subcommands: []*cli.Command{
|
||||
&image.CmdDockerFqn,
|
||||
&image.CmdDockerPush,
|
||||
&image.CmdDockerRetag,
|
||||
&image.CmdDockerBuild,
|
||||
},
|
||||
}
|
||||
|
||||
|
45
app/cmd/image/build.go
Normal file
45
app/cmd/image/build.go
Normal file
@ -0,0 +1,45 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/docker"
|
||||
)
|
||||
|
||||
var CmdDockerBuild = cli.Command{
|
||||
Name: "build",
|
||||
Aliases: []string{"b"},
|
||||
Usage: "build docker image",
|
||||
Description: `Build docker image`,
|
||||
ArgsUsage: "version",
|
||||
Action: RunDockerBuild,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "stage",
|
||||
Aliases: []string{"s"},
|
||||
Value: "",
|
||||
Usage: "select stage to build (multi-stage dockerfile)",
|
||||
Required: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
Aliases: []string{"f"},
|
||||
Value: "./Dockerfile",
|
||||
Usage: "select dockerfile",
|
||||
Required: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "opts",
|
||||
Aliases: []string{"o"},
|
||||
Value: "--compress",
|
||||
Usage: "Additional build options",
|
||||
Required: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func RunDockerBuild(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
docker.ExecDockerBuild(ctx, cmd.Args(), *cmd)
|
||||
return nil
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package docker
|
||||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/docker"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
||||
@ -17,6 +17,6 @@ var CmdDockerFqn = cli.Command{
|
||||
|
||||
func RunDockerFqn(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
fmt.Printf("%v", compose.ShowDockerImageFQN(ctx))
|
||||
fmt.Printf("%v", docker.ShowDockerImageFQN(ctx))
|
||||
return nil
|
||||
}
|
22
app/cmd/image/push.go
Normal file
22
app/cmd/image/push.go
Normal file
@ -0,0 +1,22 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/docker"
|
||||
)
|
||||
|
||||
var CmdDockerPush = cli.Command{
|
||||
Name: "push",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "push docker to registry",
|
||||
Description: `Push docker image to docker registry`,
|
||||
ArgsUsage: "version",
|
||||
Action: RunDockerPush,
|
||||
}
|
||||
|
||||
func RunDockerPush(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
docker.ExecDockerPush(ctx, cmd.Args())
|
||||
return nil
|
||||
}
|
22
app/cmd/image/retag.go
Normal file
22
app/cmd/image/retag.go
Normal file
@ -0,0 +1,22 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/docker"
|
||||
)
|
||||
|
||||
var CmdDockerRetag = cli.Command{
|
||||
Name: "retag",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "retag docker image",
|
||||
Description: `Change docker image tag`,
|
||||
ArgsUsage: "fromTag toTag",
|
||||
Action: RunDockerRetag,
|
||||
}
|
||||
|
||||
func RunDockerRetag(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
docker.ExecDockerRetag(ctx, cmd.Args())
|
||||
return nil
|
||||
}
|
@ -15,7 +15,6 @@ import (
|
||||
|
||||
var CmdInit = cli.Command{
|
||||
Name: "init",
|
||||
Aliases: []string{"i"},
|
||||
Category: catSetup,
|
||||
Usage: "Init ledo in project",
|
||||
Description: `Initialize LeadDocker in current project`,
|
||||
|
Reference in New Issue
Block a user