cmd.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. package docker
  2. import "github.com/spf13/cobra"
  3. var (
  4. varExeName string
  5. varStringGo string
  6. varStringBase string
  7. varIntPort int
  8. varStringHome string
  9. varStringRemote string
  10. varStringBranch string
  11. varStringVersion string
  12. varStringTZ string
  13. // Cmd describes a docker command.
  14. Cmd = &cobra.Command{
  15. Use: "docker",
  16. Short: "Generate Dockerfile",
  17. RunE: dockerCommand,
  18. }
  19. )
  20. func init() {
  21. Cmd.Flags().StringVar(&varExeName, "exe", "", "The executable name in the built image")
  22. Cmd.Flags().StringVar(&varStringGo, "go", "", "The file that contains main function")
  23. Cmd.Flags().StringVar(&varStringBase, "base", "scratch", "The base image to build the docker image, default scratch")
  24. Cmd.Flags().IntVar(&varIntPort, "port", 0, "The port to expose, default none")
  25. Cmd.Flags().StringVar(&varStringHome, "home", "", "The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority")
  26. Cmd.Flags().StringVar(&varStringRemote, "remote", "", "The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority\nThe git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure")
  27. Cmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it does work with --remote")
  28. Cmd.Flags().StringVar(&varStringVersion, "version", "", "The goctl builder golang image version")
  29. Cmd.Flags().StringVar(&varStringTZ, "tz", "Asia/Shanghai", "The timezone of the container")
  30. }