Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
0283ddf0d5 | |||
aee0deba4a | |||
46be715e9e | |||
1071695e87 |
12
.ledo.yml
12
.ledo.yml
@ -8,15 +8,3 @@ docker:
|
||||
modes:
|
||||
dev: docker/docker-compose.yml docker/docker-compose.dev.yml
|
||||
launch: docker/docker-compose.yml
|
||||
providers:
|
||||
# you can mix and match many files
|
||||
dotenv:
|
||||
env_sync:
|
||||
path: .env-dist
|
||||
vault:
|
||||
env_sync:
|
||||
path: environment/data/billing/web/env
|
||||
env:
|
||||
SMTP_PASS:
|
||||
path: environment/data/billing/global
|
||||
field: SMTP
|
1
Dockerfile
Normal file
1
Dockerfile
Normal file
@ -0,0 +1 @@
|
||||
FROM alpine
|
@ -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,
|
||||
@ -28,10 +25,6 @@ var CmdDocker = cli.Command{
|
||||
&docker.CmdComposeUpOnce,
|
||||
&docker.CmdComposePull,
|
||||
&docker.CmdComposeStop,
|
||||
&docker.CmdDockerLogin,
|
||||
},
|
||||
}
|
||||
|
||||
func runDockerDefault(ctx *cli.Context) error {
|
||||
return docker.RunComposePs(ctx)
|
||||
}
|
||||
|
||||
|
@ -19,5 +19,3 @@ func RunComposeBuild(cmd *cli.Context) error {
|
||||
compose.ExecComposerBuild(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,4 +18,3 @@ func RunComposeDebug(cmd *cli.Context) error {
|
||||
compose.ExecComposerDebug(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,3 @@ func RunComposeDown(cmd *cli.Context) error {
|
||||
compose.ExecComposerDown(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
32
app/cmd/docker/login.go
Normal file
32
app/cmd/docker/login.go
Normal file
@ -0,0 +1,32 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/docker"
|
||||
)
|
||||
|
||||
var CmdDockerLogin = cli.Command{
|
||||
Name: "login",
|
||||
Aliases: []string{"l"},
|
||||
Usage: "Docker Registry login",
|
||||
Description: `Login to docker registry`,
|
||||
Subcommands: []*cli.Command{
|
||||
&CmdDockerEcrLogin,
|
||||
},
|
||||
}
|
||||
|
||||
var CmdDockerEcrLogin = cli.Command{
|
||||
Name: "ecr",
|
||||
Aliases: []string{"e"},
|
||||
Usage: "AWS Elastic Docker Registry",
|
||||
Description: `Login to docker registry`,
|
||||
Action: RunDockerEcrLogin,
|
||||
}
|
||||
|
||||
func RunDockerEcrLogin(cmd *cli.Context) error {
|
||||
ctx := context.InitCommand(cmd)
|
||||
docker.DockerEcrLogin(ctx)
|
||||
return nil
|
||||
}
|
||||
|
@ -19,4 +19,3 @@ func RunComposeLogs(cmd *cli.Context) error {
|
||||
compose.ExecComposerLogs(ctx, cmd.Args())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,3 @@ func RunComposePull(cmd *cli.Context) error {
|
||||
compose.ExecComposerPull(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,3 @@ func RunComposeRestart(cmd *cli.Context) error {
|
||||
compose.ExecComposerRestart(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -23,4 +23,3 @@ func RunComposeRun(cmd *cli.Context) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -19,4 +19,3 @@ func RunComposeShell(cmd *cli.Context) error {
|
||||
compose.ExecComposerShell(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -18,5 +18,3 @@ func RunComposeStop(cmd *cli.Context) error {
|
||||
compose.ExecComposerStop(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,4 +20,3 @@ func RunComposeUp(cmd *cli.Context) error {
|
||||
compose.ExecComposerLogs(ctx, cmd.Args())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,3 @@ func RunComposeUpOnce(cmd *cli.Context) error {
|
||||
compose.ExecComposerUpOnce(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
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
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
"html/template"
|
||||
"ledo/app/helper"
|
||||
"ledo/app/modules/compose"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/modules/dockerfile"
|
||||
"ledo/app/modules/interact"
|
||||
"ledo/app/templates"
|
||||
"log"
|
||||
@ -13,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`,
|
||||
@ -21,20 +22,88 @@ var CmdInit = cli.Command{
|
||||
}
|
||||
|
||||
func runInitLedo(cmd *cli.Context) error {
|
||||
config, _ := context.LoadConfigFile()
|
||||
var advRun bool
|
||||
config, err := context.LoadConfigFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data, err := interact.InitLedoProject(config.Docker)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tpl, err := template.New("tpl").Parse(templates.LedoConfigurationFileTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
err = tpl.Execute(os.Stdout, data)
|
||||
|
||||
f, err := os.Create("./.ledo.yml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
advRun := interact.InitAdvancedConfigurationAsk()
|
||||
fmt.Printf("%v", advRun)
|
||||
err = tpl.Execute(f, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
advRun = false
|
||||
// advRun := interact.InitAdvancedConfigurationAsk("Run advanced docker mode configuration?")
|
||||
if advRun == true {
|
||||
ctx := context.InitCommand(cmd)
|
||||
dConf, _ := interact.InitDocker()
|
||||
err = dockerfile.CreateDockerFile(dConf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
projectComposeConfig := helper.DockerProjectCfg{}
|
||||
projectComposeConfig.DockerBaseImage = dConf.DockerBaseImage
|
||||
|
||||
var dockerComposeServices []helper.DockerProjectAdditionalServiceCfg
|
||||
var dockerComposeModeConfig []helper.DockerComposeModeCfg
|
||||
|
||||
|
||||
for _, composeMode := range interact.PredefinedDockerComposeModes {
|
||||
var configMode bool
|
||||
|
||||
if composeMode == "base" {
|
||||
configMode = true
|
||||
} else {
|
||||
configMode = interact.InitAdvancedConfigurationAsk("Configure "+composeMode+" stack?")
|
||||
}
|
||||
|
||||
if configMode == true {
|
||||
for {
|
||||
serviceCfg, _ := interact.CreateDockerService()
|
||||
serviceCfg.DockerServiceMode = composeMode
|
||||
dockerComposeServices = append(dockerComposeServices, serviceCfg)
|
||||
addAnother := interact.InitAdvancedConfigurationAsk("Add another service do " + composeMode + " stack?")
|
||||
if addAnother == false {
|
||||
break
|
||||
}
|
||||
}
|
||||
composeFilename := "./docker/docker-compose.yml"
|
||||
if composeMode != "base" {
|
||||
composeFilename = "./docker/docker-compose."+composeMode+".yml"
|
||||
}
|
||||
mdCfg := helper.DockerComposeModeCfg{
|
||||
DockerComposeName: composeFilename,
|
||||
DockerComposeServices: dockerComposeServices,
|
||||
}
|
||||
dockerComposeModeConfig = append(dockerComposeModeConfig, mdCfg)
|
||||
}
|
||||
}
|
||||
projectComposeConfig.DockerComposeModes = dockerComposeModeConfig
|
||||
|
||||
err = compose.CreateComposeFile(ctx, projectComposeConfig, "base")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,4 +21,3 @@ var CmdMode = cli.Command{
|
||||
func runModeDefault(cmd *cli.Context) error {
|
||||
return mode.RunSelectMode(cmd)
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,3 @@ func RunModeList(cmd *cli.Context) error {
|
||||
ctx.Mode.PrintListModes()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -24,5 +24,3 @@ func RunSelectMode(cmd *cli.Context) error {
|
||||
interact.SelectMode(ctx, "")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
77
app/helper/docker_configuration.go
Normal file
77
app/helper/docker_configuration.go
Normal file
@ -0,0 +1,77 @@
|
||||
package helper
|
||||
|
||||
type DockerServiceEnvironment struct {
|
||||
EnvironmentName string `yaml:"environment_name,omitempty" json:"environmentName"`
|
||||
EnvironmentValue string `yaml:"environment_value,omitempty" json:"environmentValue"`
|
||||
}
|
||||
|
||||
type DockerProjectAdditionalServiceCfg struct {
|
||||
DockerServiceMode string `yaml:"docker_service_mode,omitempty" json:"dockerServiceMode"`
|
||||
DockerServiceType string `yaml:"docker_service_type,omitempty" json:"dockerServiceType"`
|
||||
DockerServiceImage string `yaml:"docker_service_image,omitempty" json:"dockerServiceImage"`
|
||||
DockerServiceTag string `yaml:"docker_service_tag,omitempty" json:"dockerServiceTag"`
|
||||
DockerServiceEnvironment []DockerServiceEnvironment `yaml:"docker_service_environment,omitempty" json:"dockerServiceEnvironment"`
|
||||
}
|
||||
|
||||
type DockerComposeModeCfg struct {
|
||||
DockerComposeName string `yaml:"docker_compose_name,omitempty" json:"dockerComposeName"`
|
||||
DockerComposeServices []DockerProjectAdditionalServiceCfg `yaml:"docker_compose_services,omitempty" json:"dockerComposeServices"`
|
||||
}
|
||||
|
||||
type DockerProjectCfg struct {
|
||||
HasDockerRegistry bool `yaml:"has_docker_registry,omitempty" json:"hasDockerRegistry"`
|
||||
DockerBaseImage string `yaml:"docker_base_image,omitempty" json:"dockerBaseImage"`
|
||||
DockerBaseTag string `yaml:"docker_base_tag,omitempty" json:"dockerBaseTag"`
|
||||
DockerComposeModes []DockerComposeModeCfg `yaml:"docker_compose_modes,omitempty" json:"dockerComposeModes"`
|
||||
}
|
||||
|
||||
//var PredefinedAdditionalService = []DockerProjectAdditionalServiceCfg{
|
||||
// {
|
||||
// DockerServiceMode: "base",
|
||||
// DockerServiceType: "database",
|
||||
// DockerServiceImage: "mariadb",
|
||||
// DockerServiceTag: "",
|
||||
// DockerServiceEnvironment: []DockerServiceEnvironment{
|
||||
// {
|
||||
// EnvironmentName: "DB_NAME",
|
||||
// EnvironmentValue: "dev",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "dev",
|
||||
// DockerServiceType: "tools",
|
||||
// DockerServiceImage: "dbgate/dbgate",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "dev",
|
||||
// DockerServiceType: "tools",
|
||||
// DockerServiceImage: "mailhog/mailhog",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "dev",
|
||||
// DockerServiceType: "tools",
|
||||
// DockerServiceImage: "minio/minio",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "base",
|
||||
// DockerServiceType: "security",
|
||||
// DockerServiceImage: "authelia/authelia",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "base",
|
||||
// DockerServiceType: "infrastructure",
|
||||
// DockerServiceImage: "traefik",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
// {
|
||||
// DockerServiceMode: "base",
|
||||
// DockerServiceType: "infrastructure",
|
||||
// DockerServiceImage: "portainer",
|
||||
// DockerServiceTag: "",
|
||||
// },
|
||||
//}
|
@ -1,2 +0,0 @@
|
||||
package helper
|
||||
|
36
app/modules/aws_ledo/ecr_login.go
Normal file
36
app/modules/aws_ledo/ecr_login.go
Normal file
@ -0,0 +1,36 @@
|
||||
package aws_ledo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/ecr"
|
||||
"os"
|
||||
)
|
||||
|
||||
func getRegion() string {
|
||||
region, exists := os.LookupEnv("AWS_REGION")
|
||||
if !exists {
|
||||
fmt.Printf("AWS_REGION not set and unable to fetch region")
|
||||
os.Exit(1)
|
||||
}
|
||||
return region
|
||||
}
|
||||
|
||||
func EcrLogin() (*ecr.GetAuthorizationTokenOutput, error) {
|
||||
var input *ecr.GetAuthorizationTokenInput
|
||||
var token *ecr.GetAuthorizationTokenOutput
|
||||
|
||||
config := &aws.Config{
|
||||
Region: aws.String(getRegion()),
|
||||
}
|
||||
sess, _ := session.NewSession(config)
|
||||
_, err := sess.Config.Credentials.Get()
|
||||
if err != nil {
|
||||
return token, err
|
||||
}
|
||||
|
||||
ecrCtx := ecr.New(sess)
|
||||
token, err = ecrCtx.GetAuthorizationToken(input)
|
||||
return token, nil
|
||||
}
|
@ -3,7 +3,6 @@ package compose
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/urfave/cli/v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
@ -15,7 +14,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const DockerComposeVersion = ">= 1.28.6"
|
||||
const DockerComposeVersion = ">= 1.28.0"
|
||||
|
||||
func CheckDockerComposeVersion() {
|
||||
// cmd := exec.Command("docker-compose", "--version")
|
||||
@ -36,7 +35,7 @@ func CheckDockerComposeVersion() {
|
||||
composeSemVer, _ := semver.NewVersion(composeVersion)
|
||||
|
||||
if !verConstraint.Check(composeSemVer) {
|
||||
log.Fatal("Wrong docker-compose version, please update to 1.28.6 or higher.")
|
||||
log.Fatal("Wrong docker-compose version, please update to "+DockerComposeVersion+" or higher.")
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,11 +77,6 @@ func MergeComposerFiles(filenames ...string) (string, error) {
|
||||
return string(bs), nil
|
||||
}
|
||||
|
||||
func ShowDockerImageFQN(ctx *context.LedoContext) string {
|
||||
fqn := fmt.Sprintf("%s/%s/%s/master", ctx.Config.Docker.Registry, ctx.Config.Docker.Namespace, ctx.Config.Docker.Name)
|
||||
return strings.ToLower(fqn)
|
||||
}
|
||||
|
||||
func ExecComposerUp(ctx *context.LedoContext) {
|
||||
args := ctx.ComposeArgs
|
||||
args = append(args, "up", "-d")
|
||||
@ -107,7 +101,6 @@ func ExecComposerBuild(ctx *context.LedoContext) {
|
||||
ctx.ExecCmd("docker-compose", args[0:])
|
||||
}
|
||||
|
||||
|
||||
func ExecComposerDown(ctx *context.LedoContext) {
|
||||
args := ctx.ComposeArgs
|
||||
args = append(args, "down")
|
||||
@ -166,7 +159,3 @@ func ExecComposerUpOnce(ctx *context.LedoContext) {
|
||||
args = append(args, "up", "--force-recreate", "--renew-anon-volumes", "--abort-on-container-exit", "--exit-code-from", ctx.Config.Docker.MainService)
|
||||
ctx.ExecCmd("docker-compose", args[0:])
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
app/modules/compose/create_compose.go
Normal file
42
app/modules/compose/create_compose.go
Normal file
@ -0,0 +1,42 @@
|
||||
package compose
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"ledo/app/helper"
|
||||
"ledo/app/modules/context"
|
||||
"ledo/app/templates"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CreateComposeFile(ctx *context.LedoContext, dockerProject helper.DockerProjectCfg, composeMode string) error {
|
||||
if _, err := os.Stat("./docker"); os.IsNotExist(err) {
|
||||
err := os.Mkdir("./docker", 0755)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("%v", dockerProject)
|
||||
|
||||
templateName := templates.LedoDockerComposeBaseFileTemplate_base
|
||||
|
||||
tpl, err := template.New("dockercompose").Parse(templateName)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
composeFilename := "./docker/docker-compose.yml"
|
||||
|
||||
if composeMode != "base" {
|
||||
composeFilename = "./docker/docker-compose."+composeMode+".yml"
|
||||
}
|
||||
|
||||
f, err := os.Create(composeFilename)
|
||||
if err != nil {
|
||||
log.Println("create file: ", err)
|
||||
}
|
||||
err = tpl.Execute(f, ctx)
|
||||
|
||||
return err
|
||||
}
|
@ -39,8 +39,8 @@ func InitCommand(ctx *cli.Context) *LedoContext {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
mode := mode.InitMode(modeYml, configYml)
|
||||
c.Mode = mode
|
||||
ledoMode := mode.InitMode(modeYml, configYml)
|
||||
c.Mode = ledoMode
|
||||
|
||||
c.Output = ctx.String("output")
|
||||
|
||||
@ -50,7 +50,7 @@ func InitCommand(ctx *cli.Context) *LedoContext {
|
||||
args := []string{"--env-file", ".env"}
|
||||
args = append(args, "--project-name", strings.ToLower(strings.Replace(c.Config.Docker.Name, "/", "-", -1)))
|
||||
|
||||
composes, _ := mode.GetModeConfig()
|
||||
composes, _ := ledoMode.GetModeConfig()
|
||||
for _, element := range composes {
|
||||
args = append(args, "-f")
|
||||
args = append(args, element)
|
||||
@ -81,3 +81,11 @@ func (lx *LedoContext) ExecCmd(cmd string, cmdArgs []string) error {
|
||||
command.Stderr = os.Stderr
|
||||
return command.Run()
|
||||
}
|
||||
|
||||
func (lx *LedoContext) ExecCmdSilent(cmd string, cmdArgs []string) error {
|
||||
command := exec.Command(cmd, cmdArgs...)
|
||||
command.Stdin = os.Stdin
|
||||
command.Stdout = os.Stdout
|
||||
command.Stderr = nil
|
||||
return command.Run()
|
||||
}
|
||||
|
95
app/modules/docker/docker.go
Normal file
95
app/modules/docker/docker.go
Normal file
@ -0,0 +1,95 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ledo/app/modules/aws_ledo"
|
||||
"ledo/app/modules/context"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func trimLeftChars(s string, n int) string {
|
||||
m := 0
|
||||
for i := range s {
|
||||
if m >= n {
|
||||
return s[i:]
|
||||
}
|
||||
m++
|
||||
}
|
||||
return s[:0]
|
||||
}
|
||||
|
||||
func DockerEcrLogin(ctx *context.LedoContext) error {
|
||||
ecr, err := aws_ledo.EcrLogin()
|
||||
if err != nil {
|
||||
fmt.Println("Ecr login error: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
password := *ecr.AuthorizationData[0].AuthorizationToken
|
||||
ecrUrl := *ecr.AuthorizationData[0].ProxyEndpoint
|
||||
sDec, _ := b64.StdEncoding.DecodeString(password)
|
||||
registryAddr, err := url.Parse(ecrUrl)
|
||||
if err != nil {
|
||||
fmt.Printf("Ecr endpoint addr parse error: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
ctx.ExecCmdSilent("docker", []string{"login", "-u", "AWS", "-p", string(trimLeftChars(string(sDec), 4)), registryAddr.Host})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ShowDockerImageFQN(ctx *context.LedoContext) string {
|
||||
fqn := fmt.Sprintf("%s/%s/%s", ctx.Config.Docker.Registry, ctx.Config.Docker.Namespace, ctx.Config.Docker.Name)
|
||||
return strings.ToLower(fqn)
|
||||
}
|
||||
|
||||
func ExecDockerPush(ctx *context.LedoContext, command cli.Args) {
|
||||
var version string
|
||||
var args []string
|
||||
if command.First() == "" {
|
||||
version = "latest"
|
||||
} else {
|
||||
version = command.First()
|
||||
}
|
||||
image := ShowDockerImageFQN(ctx)
|
||||
args = append(args, "push")
|
||||
args = append(args, "-f", image + ":" + version)
|
||||
ctx.ExecCmd("docker", args[0:])
|
||||
}
|
||||
|
||||
func ExecDockerRetag(ctx *context.LedoContext, command cli.Args) {
|
||||
var args []string
|
||||
|
||||
from := command.Get(0)
|
||||
to := command.Get(1)
|
||||
image := ShowDockerImageFQN(ctx)
|
||||
args = append(args, "tag")
|
||||
args = append(args, image + ":" + from)
|
||||
args = append(args, image + ":" + to)
|
||||
ctx.ExecCmd("docker", args[0:])
|
||||
}
|
||||
|
||||
func ExecDockerBuild(ctx *context.LedoContext, command cli.Args, cmdCtx cli.Context) {
|
||||
var version string
|
||||
var args []string
|
||||
if command.First() == "" {
|
||||
version = "latest"
|
||||
} else {
|
||||
version = command.First()
|
||||
}
|
||||
|
||||
opts := strings.Split(strings.Trim(cmdCtx.String("opts"), " "), " ")
|
||||
image := ShowDockerImageFQN(ctx)
|
||||
args = append(args, "build")
|
||||
args = append(args, "-t", image+":"+version)
|
||||
args = append(args, "-f", cmdCtx.String("dockerfile"))
|
||||
args = append(args, opts...)
|
||||
if cmdCtx.String("stage") != "" {
|
||||
args = append(args, "--target", cmdCtx.String("stage"))
|
||||
}
|
||||
args = append(args, ".")
|
||||
ctx.ExecCmd("docker", args[0:])
|
||||
}
|
57
app/modules/docker_hub/docker_hub_images.go
Normal file
57
app/modules/docker_hub/docker_hub_images.go
Normal file
@ -0,0 +1,57 @@
|
||||
package docker_hub
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type DockerSearchResponse struct {
|
||||
NumPages int `json:"num_pages"`
|
||||
NumResults int `json:"num_results"`
|
||||
PageSize int `json:"page_size"`
|
||||
Page int `json:"page"`
|
||||
Query string `json:"query"`
|
||||
Results []DockerImage `json:"results"`
|
||||
}
|
||||
|
||||
type DockerImage struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
StarCount int `json:"star_count"`
|
||||
IsTrusted bool `json:"is_trusted"`
|
||||
IsAutomated bool `json:"is_automated"`
|
||||
IsOfficial bool `json:"is_official"`
|
||||
}
|
||||
|
||||
var urlSearch = "https://registry.hub.docker.com/v1/search"
|
||||
|
||||
func GetImage(image string) []DockerImage {
|
||||
var resp DockerSearchResponse
|
||||
searchString := url.QueryEscape(image)
|
||||
urlSearch = urlSearch + "/?q=" + searchString
|
||||
fmt.Printf("%v", urlSearch)
|
||||
res, _ := http.Get(urlSearch)
|
||||
defer res.Body.Close()
|
||||
|
||||
bytes, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
json.Unmarshal(bytes, &resp)
|
||||
|
||||
return resp.Results
|
||||
}
|
||||
|
||||
func DockerImageToArray(images []DockerImage) []string {
|
||||
n := len(images)
|
||||
arrTags := make([]string, n)
|
||||
for idx, image := range images {
|
||||
arrTags[idx] = image.Name
|
||||
}
|
||||
|
||||
return arrTags
|
||||
}
|
@ -11,11 +11,11 @@ type DockerImageTag struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
var url = "https://registry.hub.docker.com/v1/repositories"
|
||||
var urlTags = "https://registry.hub.docker.com/v1/repositories"
|
||||
|
||||
func GetImageTags(image string) []DockerImageTag {
|
||||
url = url + "/" + image + "/tags"
|
||||
res, _ := http.Get(url)
|
||||
urlTags = urlTags + "/" + image + "/tags"
|
||||
res, _ := http.Get(urlTags)
|
||||
defer res.Body.Close()
|
||||
|
||||
bytes, err := ioutil.ReadAll(res.Body)
|
33
app/modules/dockerfile/dockerfile.go
Normal file
33
app/modules/dockerfile/dockerfile.go
Normal file
@ -0,0 +1,33 @@
|
||||
package dockerfile
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"ledo/app/helper"
|
||||
"ledo/app/templates"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CreateDockerFile(cfg helper.DockerProjectCfg) error {
|
||||
if _, err := os.Stat("./Dockerfile"); err == nil {
|
||||
log.Printf("Dockerfile exists!")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
templateName := templates.DockerFileTemplate_default
|
||||
if cfg.DockerBaseImage == "paramah/php" {
|
||||
templateName = templates.DockerFileTemplate_php
|
||||
}
|
||||
tpl, err := template.New("dockerfile").Parse(templateName)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
f, err := os.Create("./Dockerfile")
|
||||
if err != nil {
|
||||
log.Println("create file: ", err)
|
||||
}
|
||||
err = tpl.Execute(f, cfg)
|
||||
|
||||
return err
|
||||
}
|
64
app/modules/interact/docker_hub.go
Normal file
64
app/modules/interact/docker_hub.go
Normal file
@ -0,0 +1,64 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"ledo/app/modules/docker_hub"
|
||||
)
|
||||
|
||||
func SelectDockerHubTag(dockerImage string) (string, error) {
|
||||
dockerImageTags := docker_hub.GetImageTags(dockerImage)
|
||||
selectedTag := "latest"
|
||||
|
||||
var qs = []*survey.Question{
|
||||
{
|
||||
Name: "tags",
|
||||
Prompt: &survey.Select{
|
||||
Message: "Select available docker image tag",
|
||||
PageSize: 10,
|
||||
Options: docker_hub.ImageTagsToArray(dockerImageTags),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := survey.Ask(qs, &selectedTag)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return selectedTag, err
|
||||
}
|
||||
|
||||
func EnterDockerImage() (string, error) {
|
||||
dockerImage := ""
|
||||
prompt := &survey.Input{
|
||||
Message: "Enter docker base image: ",
|
||||
Help: "This is base Dockerfile image (FROM image)",
|
||||
}
|
||||
survey.AskOne(prompt, &dockerImage)
|
||||
return dockerImage, nil
|
||||
}
|
||||
|
||||
func SearchDockerImage(image string) (string, error) {
|
||||
dockerImages := docker_hub.GetImage(image)
|
||||
selectedImage := ""
|
||||
|
||||
var qs = []*survey.Question{
|
||||
{
|
||||
Name: "image",
|
||||
Prompt: &survey.Select{
|
||||
Message: "Select available docker image",
|
||||
PageSize: 100,
|
||||
Options: docker_hub.DockerImageToArray(dockerImages),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := survey.Ask(qs, &selectedImage)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return selectedImage, err
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
survey "github.com/AlecAivazis/survey/v2"
|
||||
"ledo/app/modules/docker_hub"
|
||||
)
|
||||
|
||||
func SelectDockerHubTag(dockerImage string) (string, error) {
|
||||
dockerImageTags := docker_hub.GetImageTags(dockerImage)
|
||||
selectedTag := "latest"
|
||||
|
||||
var qs = []*survey.Question{
|
||||
{
|
||||
Name: "tags",
|
||||
Prompt: &survey.Select{
|
||||
Message: "Select available docker image tag",
|
||||
PageSize: 10,
|
||||
Options: docker_hub.ImageTagsToArray(dockerImageTags),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := survey.Ask(qs, &selectedTag)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return selectedTag, err
|
||||
}
|
24
app/modules/interact/docker_init.go
Normal file
24
app/modules/interact/docker_init.go
Normal file
@ -0,0 +1,24 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
"ledo/app/helper"
|
||||
)
|
||||
|
||||
func InitDocker() (helper.DockerProjectCfg, error) {
|
||||
dockerConfig := helper.DockerProjectCfg{}
|
||||
|
||||
image, err := EnterDockerImage()
|
||||
if err != nil {
|
||||
return dockerConfig, err
|
||||
}
|
||||
|
||||
tag, err := SelectDockerHubTag(image)
|
||||
if err != nil {
|
||||
return dockerConfig, err
|
||||
}
|
||||
|
||||
dockerConfig.DockerBaseImage = image
|
||||
dockerConfig.DockerBaseTag = tag
|
||||
|
||||
return dockerConfig, err
|
||||
}
|
51
app/modules/interact/docker_service.go
Normal file
51
app/modules/interact/docker_service.go
Normal file
@ -0,0 +1,51 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"ledo/app/helper"
|
||||
)
|
||||
|
||||
var PredefinedDockerComposeModes = []string{
|
||||
"base",
|
||||
"dev",
|
||||
"test",
|
||||
}
|
||||
|
||||
func CreateDockerService() (helper.DockerProjectAdditionalServiceCfg, error) {
|
||||
dockerServiceConfig := helper.DockerProjectAdditionalServiceCfg{}
|
||||
|
||||
var qs = []*survey.Question{
|
||||
//{
|
||||
// Name: "DockerServiceType",
|
||||
// Prompt: &survey.Select{
|
||||
// Message: "Select type of service",
|
||||
// PageSize: 10,
|
||||
// Options: []string{"database", "development", "tools"},
|
||||
// },
|
||||
//},
|
||||
//{
|
||||
// Name: "DockerServiceMode",
|
||||
// Prompt: &survey.Select{
|
||||
// Message: "Select docker-compose mode (file)",
|
||||
// PageSize: 10,
|
||||
// Options: PredefinedDockerComposeModes,
|
||||
// },
|
||||
//},
|
||||
{
|
||||
Name: "DockerServiceImage",
|
||||
Prompt: &survey.Input{Message: "Enter image name: "},
|
||||
Validate: survey.Required,
|
||||
Transform: survey.ToLower,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
err := survey.Ask(qs, &dockerServiceConfig)
|
||||
|
||||
if err != nil {
|
||||
return dockerServiceConfig, err
|
||||
}
|
||||
|
||||
return dockerServiceConfig, err
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
|
||||
package interact
|
||||
|
||||
import (
|
||||
survey "github.com/AlecAivazis/survey/v2"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"ledo/app/modules/config"
|
||||
)
|
||||
|
||||
func InitLedoProject(dockerConfig config.DockerMap) (config.DockerMap, error) {
|
||||
if dockerConfig.Registry == "" {
|
||||
dockerConfig.Registry = "hub.docker.com"
|
||||
dockerConfig.Registry = ""
|
||||
}
|
||||
|
||||
if dockerConfig.Shell == "" {
|
||||
@ -28,7 +27,7 @@ func InitLedoProject(dockerConfig config.DockerMap) (config.DockerMap, error) {
|
||||
},
|
||||
{
|
||||
Name: "Namespace",
|
||||
Prompt: &survey.Input{Message: "Enter project namespace: ",Default: dockerConfig.Namespace, Help: "Project namespace (eq. GitLab project group)"},
|
||||
Prompt: &survey.Input{Message: "Enter project namespace: ", Default: dockerConfig.Namespace, Help: "Project namespace (eq. GitLab project group)"},
|
||||
Validate: survey.Required,
|
||||
Transform: survey.ToLower,
|
||||
},
|
||||
@ -40,7 +39,7 @@ func InitLedoProject(dockerConfig config.DockerMap) (config.DockerMap, error) {
|
||||
},
|
||||
{
|
||||
Name: "MainService",
|
||||
Prompt: &survey.Input{Message: "Enter docker-compose main service name: ",Default: dockerConfig.MainService, Help: "Main service, important if you want use ledo shell command or ledo run command"},
|
||||
Prompt: &survey.Input{Message: "Enter docker-compose main service name: ", Default: dockerConfig.MainService, Help: "Main service, important if you want use ledo shell command or ledo run command"},
|
||||
Validate: survey.Required,
|
||||
Transform: survey.ToLower,
|
||||
},
|
||||
@ -56,7 +55,6 @@ func InitLedoProject(dockerConfig config.DockerMap) (config.DockerMap, error) {
|
||||
Validate: survey.Required,
|
||||
Transform: survey.ToLower,
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
err := survey.Ask(qs, &dockerConfig)
|
||||
@ -68,9 +66,9 @@ func InitLedoProject(dockerConfig config.DockerMap) (config.DockerMap, error) {
|
||||
return dockerConfig, err
|
||||
}
|
||||
|
||||
func InitAdvancedConfigurationAsk() (bool) {
|
||||
func InitAdvancedConfigurationAsk(question string) bool {
|
||||
runAdv := false
|
||||
prompt := &survey.Confirm{Message: "Run advanced docker mode configuration?"}
|
||||
prompt := &survey.Confirm{Message: question}
|
||||
survey.AskOne(prompt, &runAdv)
|
||||
return runAdv
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
survey "github.com/AlecAivazis/survey/v2"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/thoas/go-funk"
|
||||
"ledo/app/modules/context"
|
||||
)
|
||||
|
@ -58,7 +58,7 @@ func (c *Mode) GetMode() string {
|
||||
|
||||
func (c *Mode) PrintListModes() {
|
||||
fmt.Printf("Available modes:\n")
|
||||
for m, _ := range c.availableModes {
|
||||
for m := range c.availableModes {
|
||||
fmt.Printf("- %v\n", m)
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ func (c *Mode) SetMode(modeName string) (bool, error) {
|
||||
}
|
||||
|
||||
func (c *Mode) GetModeConfig() ([]string, error) {
|
||||
_, err := c.CheckMode(c.CurrentMode);
|
||||
_, err := c.CheckMode(c.CurrentMode)
|
||||
|
||||
if err == nil {
|
||||
composes := strings.Fields(c.availableModes[c.CurrentMode])
|
||||
@ -105,5 +105,3 @@ func (c *Mode) GetModeConfig() ([]string, error) {
|
||||
|
||||
return nil, errors.New("Selected mode not exists in config file")
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,15 @@
|
||||
package templates
|
||||
|
||||
var LedoDockerComposeBaseFileTemplate = `
|
||||
var LedoDockerComposeBaseFileTemplate_base = `
|
||||
version: '3.7'
|
||||
services:
|
||||
|
||||
{{.Config.Docker.MainService}}:
|
||||
image: {{.Config.Docker.Registry}}
|
||||
networks:
|
||||
- network-{{.Config.Docker.Namespace}}
|
||||
env_file: ${PWD}/.env
|
||||
|
||||
networks:
|
||||
nestork-{{.Config.Docker.Namespace}}: {}
|
||||
`
|
@ -1,7 +1,7 @@
|
||||
package templates
|
||||
|
||||
var default_DockerFileTemplate = `
|
||||
FROM {{.Image}}/{{.Tag}}
|
||||
var DockerFileTemplate_default = `
|
||||
FROM {{.DockerBaseImage}}:{{.DockerBaseTag}}
|
||||
|
||||
ENV DIR /usr/local
|
||||
WORKDIR ${DIR}
|
||||
@ -10,13 +10,13 @@ WORKDIR ${DIR}
|
||||
COPY docker/docker-entrypoint.sh /bin/docker-entrypoint.sh
|
||||
|
||||
# Copy project content
|
||||
COPY {{.ContainerContent}} $DIR
|
||||
COPY ./app $DIR
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
CMD [""]
|
||||
`
|
||||
var php_DockerFileTemplate = `
|
||||
FROM paramah/{{.Tag}}
|
||||
var DockerFileTemplate_php = `
|
||||
FROM {{.DockerBaseImage}}:{{.DockerBaseTag}}
|
||||
ARG ENVIRONMENT=production
|
||||
|
||||
RUN ngxconfig sf.conf
|
||||
|
31
app/templates/entrypoint_template.go
Normal file
31
app/templates/entrypoint_template.go
Normal file
@ -0,0 +1,31 @@
|
||||
package templates
|
||||
|
||||
var DockerEntrypointTemplate_bash = `
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
h1() {
|
||||
declare border padding text
|
||||
border='\e[1;34m'"$(printf '=%.0s' $(seq 1 "$term_width"))"'\e[0m'
|
||||
padding="$(printf ' %.0s' $(seq 1 $(((term_width - $(wc -m <<<"$*")) / 2))))"
|
||||
text="\\e[1m$*\\e[0m"
|
||||
echo -e "$border"
|
||||
echo -e "${padding}${text}${padding}"
|
||||
echo -e "$border"
|
||||
}
|
||||
|
||||
h2() {
|
||||
printf '\e[1;33m==>\e[37;1m %s\e[0m\n' "$*"
|
||||
}
|
||||
|
||||
h1 "Project init"
|
||||
|
||||
###
|
||||
### Your code here
|
||||
###
|
||||
|
||||
h1 "End of init"
|
||||
|
||||
exec "$@"
|
||||
`
|
@ -11,8 +11,7 @@ docker:
|
||||
username: {{.Username}}
|
||||
{{end}}
|
||||
modes:
|
||||
normal: docker/docker-compose.yml
|
||||
base: docker/docker-compose.yml
|
||||
dev: docker/docker-compose.yml docker/docker-compose.dev.yml
|
||||
traefik: docker/docker-compose.yml docker/docker-compose.traefik.yml
|
||||
test: docker/docker-compose.yml docker/docker-compose.test.yml
|
||||
`
|
||||
|
||||
|
4
go.mod
4
go.mod
@ -6,6 +6,7 @@ require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.2
|
||||
github.com/Masterminds/semver v1.5.0
|
||||
github.com/adrg/xdg v0.3.4
|
||||
github.com/aws/aws-sdk-go v1.42.15
|
||||
github.com/sanbornm/go-selfupdate v0.0.0-20210106163404-c9b625feac49
|
||||
github.com/spf13/viper v1.8.1
|
||||
github.com/thoas/go-funk v0.9.1
|
||||
@ -17,6 +18,7 @@ require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/kr/binarydist v0.1.0 // indirect
|
||||
@ -37,7 +39,7 @@ require (
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b // indirect
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/inconshreveable/go-update.v0 v0.0.0-20150814200126-d8b0b1d421aa // indirect
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
|
12
go.sum
12
go.sum
@ -51,6 +51,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aws/aws-sdk-go v1.42.15 h1:RcUChuF7KzrrTqx9LAzJbLBX00LkUY7cH9T1VdxNdqk=
|
||||
github.com/aws/aws-sdk-go v1.42.15/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
@ -174,6 +176,10 @@ github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDG
|
||||
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
@ -224,6 +230,7 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
|
||||
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
|
||||
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -365,6 +372,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -429,6 +437,7 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b h1:S7hKs0Flbq0bbc9xgYt4stIEG1zNDFqyrPwAX2Wj/sE=
|
||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -441,8 +450,9 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
5
main.go
5
main.go
@ -25,13 +25,14 @@ func main() {
|
||||
app.Usage = "LeadDocker helper for docker-compose work"
|
||||
app.Description = appDescription
|
||||
app.CustomAppHelpTemplate = helpTemplate
|
||||
app.Version = version
|
||||
app.Version = GetCurrentVersion()
|
||||
app.Commands = []*cli.Command{
|
||||
&cmd.CmdInit,
|
||||
&cmd.CmdDocker,
|
||||
&cmd.CmdImage,
|
||||
&cmd.CmdMode,
|
||||
&cmd.CmdAutocomplete,
|
||||
&CmdSelfupdate,
|
||||
// &CmdSelfupdate,
|
||||
}
|
||||
app.EnableBashCompletion = true
|
||||
err := app.Run(os.Args)
|
||||
|
Loading…
Reference in New Issue
Block a user