fix: generate bad Dockerfile on given dir (#1980)

This commit is contained in:
Kevin Wan
2022-06-06 19:50:54 +08:00
committed by GitHub
parent 8be47b9c99
commit 4d34998338
3 changed files with 3 additions and 8 deletions

View File

@@ -151,17 +151,12 @@ func generateDockerfile(goFile, base string, port int, version, timezone string,
builder.WriteString(`, "` + arg + `"`)
}
absGoPath, err := filepath.Abs(goFile)
if err != nil {
return err
}
t := template.Must(template.New("dockerfile").Parse(text))
return t.Execute(out, Docker{
Chinese: env.InChina(),
GoRelPath: projPath,
GoFile: goFile,
ExeFile: filepath.Base(absGoPath),
ExeFile: pathx.FileNameWithoutExt(filepath.Base(goFile)),
BaseImage: base,
HasPort: port > 0,
Port: port,