2022-01-06 20:27:18 +08:00
|
|
|
package golang
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
|
|
|
|
2022-01-10 20:26:14 +08:00
|
|
|
"git.icechen.cn/pkg/wujian_develop_tool/config"
|
|
|
|
|
2022-01-06 20:27:18 +08:00
|
|
|
"github.com/fatih/color"
|
|
|
|
|
2022-01-06 23:04:25 +08:00
|
|
|
"git.icechen.cn/pkg/wujian_develop_tool/util"
|
2022-01-06 20:27:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed "Dockerfile.tpl"
|
|
|
|
var dockerfileTemplate string
|
|
|
|
|
2022-01-06 22:32:03 +08:00
|
|
|
//go:embed "main.tpl"
|
|
|
|
var mainGoTemplate string
|
|
|
|
|
2022-01-10 20:26:14 +08:00
|
|
|
func GenDockerfile(api config.Api) error {
|
2022-01-06 20:27:18 +08:00
|
|
|
color.Green("正在生成dockerfile...")
|
2022-01-10 20:26:14 +08:00
|
|
|
err := util.TemplateToFile(api.Root+"/Dockerfile", dockerfileTemplate, api)
|
2022-01-06 22:32:03 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-01-10 20:26:14 +08:00
|
|
|
return util.TemplateToFile(api.Root+"/main.go", mainGoTemplate, nil)
|
2022-01-06 20:27:18 +08:00
|
|
|
}
|