|
|
@ -28,7 +28,7 @@ type Docker struct {
|
|
|
|
GoRelPath string
|
|
|
|
GoRelPath string
|
|
|
|
GoFile string
|
|
|
|
GoFile string
|
|
|
|
ExeFile string
|
|
|
|
ExeFile string
|
|
|
|
Scratch bool
|
|
|
|
BaseImage string
|
|
|
|
HasPort bool
|
|
|
|
HasPort bool
|
|
|
|
Port int
|
|
|
|
Port int
|
|
|
|
Argument string
|
|
|
|
Argument string
|
|
|
@ -74,10 +74,10 @@ func DockerCommand(c *cli.Context) (err error) {
|
|
|
|
return fmt.Errorf("file %q not found", goFile)
|
|
|
|
return fmt.Errorf("file %q not found", goFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
scratch := c.Bool("scratch")
|
|
|
|
base := c.String("base")
|
|
|
|
port := c.Int("port")
|
|
|
|
port := c.Int("port")
|
|
|
|
if _, err := os.Stat(etcDir); os.IsNotExist(err) {
|
|
|
|
if _, err := os.Stat(etcDir); os.IsNotExist(err) {
|
|
|
|
return generateDockerfile(goFile, scratch, port, version, timezone)
|
|
|
|
return generateDockerfile(goFile, base, port, version, timezone)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cfg, err := findConfig(goFile, etcDir)
|
|
|
|
cfg, err := findConfig(goFile, etcDir)
|
|
|
@ -85,7 +85,7 @@ func DockerCommand(c *cli.Context) (err error) {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := generateDockerfile(goFile, scratch, port, version, timezone, "-f", "etc/"+cfg); err != nil {
|
|
|
|
if err := generateDockerfile(goFile, base, port, version, timezone, "-f", "etc/"+cfg); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +126,7 @@ func findConfig(file, dir string) (string, error) {
|
|
|
|
return files[0], nil
|
|
|
|
return files[0], nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func generateDockerfile(goFile string, scratch bool, port int, version, timezone string, args ...string) error {
|
|
|
|
func generateDockerfile(goFile, base string, port int, version, timezone string, args ...string) error {
|
|
|
|
projPath, err := getFilePath(filepath.Dir(goFile))
|
|
|
|
projPath, err := getFilePath(filepath.Dir(goFile))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -159,7 +159,7 @@ func generateDockerfile(goFile string, scratch bool, port int, version, timezone
|
|
|
|
GoRelPath: projPath,
|
|
|
|
GoRelPath: projPath,
|
|
|
|
GoFile: goFile,
|
|
|
|
GoFile: goFile,
|
|
|
|
ExeFile: pathx.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
ExeFile: pathx.FileNameWithoutExt(filepath.Base(goFile)),
|
|
|
|
Scratch: scratch,
|
|
|
|
BaseImage: base,
|
|
|
|
HasPort: port > 0,
|
|
|
|
HasPort: port > 0,
|
|
|
|
Port: port,
|
|
|
|
Port: port,
|
|
|
|
Argument: builder.String(),
|
|
|
|
Argument: builder.String(),
|
|
|
|