|
|
@ -16,9 +16,10 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
etcDir = "etc"
|
|
|
|
dockerfileName = "Dockerfile"
|
|
|
|
yamlEtx = ".yaml"
|
|
|
|
etcDir = "etc"
|
|
|
|
cstOffset = 60 * 60 * 8 // 8 hours offset for Chinese Standard Time
|
|
|
|
yamlEtx = ".yaml"
|
|
|
|
|
|
|
|
cstOffset = 60 * 60 * 8 // 8 hours offset for Chinese Standard Time
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Docker struct {
|
|
|
|
type Docker struct {
|
|
|
@ -26,6 +27,7 @@ type Docker struct {
|
|
|
|
GoRelPath string
|
|
|
|
GoRelPath string
|
|
|
|
GoFile string
|
|
|
|
GoFile string
|
|
|
|
ExeFile string
|
|
|
|
ExeFile string
|
|
|
|
|
|
|
|
HasArgs bool
|
|
|
|
Argument string
|
|
|
|
Argument string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -96,12 +98,16 @@ func generateDockerfile(goFile string, args ...string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pos := strings.IndexByte(projPath, '/')
|
|
|
|
if len(projPath) == 0 {
|
|
|
|
if pos >= 0 {
|
|
|
|
projPath = "."
|
|
|
|
projPath = projPath[pos+1:]
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pos := strings.IndexByte(projPath, os.PathSeparator)
|
|
|
|
|
|
|
|
if pos >= 0 {
|
|
|
|
|
|
|
|
projPath = projPath[pos+1:]
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
out, err := util.CreateIfNotExist("Dockerfile")
|
|
|
|
out, err := util.CreateIfNotExist(dockerfileName)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -124,6 +130,7 @@ func generateDockerfile(goFile string, args ...string) error {
|
|
|
|
GoRelPath: projPath,
|
|
|
|
GoRelPath: projPath,
|
|
|
|
GoFile: goFile,
|
|
|
|
GoFile: goFile,
|
|
|
|
ExeFile: util.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
ExeFile: util.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
|
|
|
|
HasArgs: builder.Len() > 0,
|
|
|
|
Argument: builder.String(),
|
|
|
|
Argument: builder.String(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|