|
|
@ -32,6 +32,8 @@ type Docker struct {
|
|
|
|
Port int
|
|
|
|
Port int
|
|
|
|
Argument string
|
|
|
|
Argument string
|
|
|
|
Version string
|
|
|
|
Version string
|
|
|
|
|
|
|
|
HasTimezone bool
|
|
|
|
|
|
|
|
Timezone string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// DockerCommand provides the entry for goctl docker
|
|
|
|
// DockerCommand provides the entry for goctl docker
|
|
|
@ -47,6 +49,7 @@ func DockerCommand(c *cli.Context) (err error) {
|
|
|
|
version := c.String("version")
|
|
|
|
version := c.String("version")
|
|
|
|
remote := c.String("remote")
|
|
|
|
remote := c.String("remote")
|
|
|
|
branch := c.String("branch")
|
|
|
|
branch := c.String("branch")
|
|
|
|
|
|
|
|
timezone := c.String("tz")
|
|
|
|
if len(remote) > 0 {
|
|
|
|
if len(remote) > 0 {
|
|
|
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
|
|
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
|
|
|
if len(repo) > 0 {
|
|
|
|
if len(repo) > 0 {
|
|
|
@ -72,7 +75,7 @@ func DockerCommand(c *cli.Context) (err error) {
|
|
|
|
|
|
|
|
|
|
|
|
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, port, version)
|
|
|
|
return generateDockerfile(goFile, port, version, timezone)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cfg, err := findConfig(goFile, etcDir)
|
|
|
|
cfg, err := findConfig(goFile, etcDir)
|
|
|
@ -80,7 +83,7 @@ func DockerCommand(c *cli.Context) (err error) {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := generateDockerfile(goFile, port, version, "-f", "etc/"+cfg); err != nil {
|
|
|
|
if err := generateDockerfile(goFile, port, version, timezone, "-f", "etc/"+cfg); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -121,7 +124,7 @@ func findConfig(file, dir string) (string, error) {
|
|
|
|
return files[0], nil
|
|
|
|
return files[0], nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func generateDockerfile(goFile string, port int, version string, args ...string) error {
|
|
|
|
func generateDockerfile(goFile 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
|
|
|
@ -158,6 +161,8 @@ func generateDockerfile(goFile string, port int, version string, args ...string)
|
|
|
|
Port: port,
|
|
|
|
Port: port,
|
|
|
|
Argument: builder.String(),
|
|
|
|
Argument: builder.String(),
|
|
|
|
Version: version,
|
|
|
|
Version: version,
|
|
|
|
|
|
|
|
HasTimezone: len(timezone) > 0,
|
|
|
|
|
|
|
|
Timezone: timezone,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|