|
|
@ -6,6 +6,7 @@ import (
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
|
|
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
|
|
|
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
|
|
@ -15,8 +16,17 @@ import (
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
etcDir = "etc"
|
|
|
|
etcDir = "etc"
|
|
|
|
yamlEtx = ".yaml"
|
|
|
|
yamlEtx = ".yaml"
|
|
|
|
|
|
|
|
cstOffset = 60 * 60 * 8 // 8 hours offset for Chinese Standard Time
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Docker struct {
|
|
|
|
|
|
|
|
Chinese bool
|
|
|
|
|
|
|
|
GoRelPath string
|
|
|
|
|
|
|
|
GoFile string
|
|
|
|
|
|
|
|
ExeFile string
|
|
|
|
|
|
|
|
Argument string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DockerCommand(c *cli.Context) error {
|
|
|
|
func DockerCommand(c *cli.Context) error {
|
|
|
|
goFile := c.String("go")
|
|
|
|
goFile := c.String("go")
|
|
|
|
if len(goFile) == 0 {
|
|
|
|
if len(goFile) == 0 {
|
|
|
@ -87,12 +97,14 @@ func generateDockerfile(goFile string, args ...string) error {
|
|
|
|
builder.WriteString(`, "` + arg + `"`)
|
|
|
|
builder.WriteString(`, "` + arg + `"`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_, offset := time.Now().Zone()
|
|
|
|
t := template.Must(template.New("dockerfile").Parse(text))
|
|
|
|
t := template.Must(template.New("dockerfile").Parse(text))
|
|
|
|
return t.Execute(out, map[string]string{
|
|
|
|
return t.Execute(out, Docker{
|
|
|
|
"goRelPath": projPath,
|
|
|
|
Chinese: offset == cstOffset,
|
|
|
|
"goFile": goFile,
|
|
|
|
GoRelPath: projPath,
|
|
|
|
"exeFile": util.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
GoFile: goFile,
|
|
|
|
"argument": builder.String(),
|
|
|
|
ExeFile: util.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
|
|
|
|
Argument: builder.String(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|