cmd.go 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. package docker
  2. import "github.com/spf13/cobra"
  3. var (
  4. varStringGo string
  5. varStringBase string
  6. varIntPort int
  7. varStringHome string
  8. varStringRemote string
  9. varStringBranch string
  10. varStringVersion string
  11. varStringTZ string
  12. // Cmd describes a docker command.
  13. Cmd = &cobra.Command{
  14. Use: "docker",
  15. Short: "Generate Dockerfile",
  16. RunE: dockerCommand,
  17. }
  18. )
  19. func init() {
  20. Cmd.Flags().StringVar(&varStringGo, "go", ".", "The directory that contains main function")
  21. Cmd.Flags().StringVar(&varStringBase, "base", "scratch", "The base image to build the docker image, default scratch")
  22. Cmd.Flags().IntVar(&varIntPort, "port", 0, "The port to expose, default none")
  23. 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")
  24. 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\n\tThe git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure")
  25. Cmd.Flags().StringVar(&varStringBranch, "branch", "", "The branch of the remote repo, it does work with --remote")
  26. Cmd.Flags().StringVar(&varStringVersion, "version", "", "The goctl builder golang image version")
  27. Cmd.Flags().StringVar(&varStringTZ, "tz", "Asia/Shanghai", "The timezone of the container")
  28. }