fix dockerfile generation

This commit is contained in:
kevin
2020-08-31 12:27:38 +08:00
parent eb40c2731d
commit 7b17b3604a
3 changed files with 31 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
package gen
import (
"path/filepath"
"strings"
"text/template"
@@ -9,11 +10,16 @@ import (
)
func GenerateDockerfile(goFile string, args ...string) error {
projPath, err := getFilePath(goFile)
projPath, err := getFilePath(filepath.Dir(goFile))
if err != nil {
return err
}
pos := strings.IndexByte(projPath, '/')
if pos >= 0 {
projPath = projPath[pos+1:]
}
out, err := util.CreateIfNotExist("Dockerfile")
if err != nil {
return err