brew-cli 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env python
  2. import argparse
  3. import logging
  4. import sys
  5. try:
  6. import brew
  7. except ImportError as e:
  8. print str(e)
  9. print 'Please install the required dependencies first'
  10. print 'sudo pip install -r requirements.txt'
  11. sys.exit(1)
  12. logger = logging.getLogger(__name__)
  13. logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
  14. level='INFO')
  15. if __name__ == '__main__':
  16. parser = argparse.ArgumentParser('Build the docker standard library')
  17. parser.add_argument(
  18. '--push', action='store_true', default=False,
  19. help='Push generated repositories'
  20. )
  21. parser.add_argument(
  22. '--debug', default=False, action='store_true',
  23. help='Enable debugging output'
  24. )
  25. # parser.add_argument(
  26. # '--noprefill', default=True, action='store_false',
  27. # dest='prefill', help='Disable cache prefill'
  28. # )
  29. parser.add_argument(
  30. '-n', metavar='NAMESPACE', default='library',
  31. help='Comma-separated list of namespaces used for generated'
  32. ' repositories. Default is library'
  33. )
  34. parser.add_argument(
  35. '--no-namespace', default=False, action='store_true',
  36. help='In addition to -n, also tag generated images with no'
  37. ' namespace (ie, "library/busybox" as "busybox")'
  38. )
  39. parser.add_argument(
  40. '-b', metavar='BRANCH', default=brew.DEFAULT_BRANCH,
  41. help='Branch in the repository where the library definition'
  42. ' files will be fetched. Default is ' + brew.DEFAULT_BRANCH
  43. )
  44. parser.add_argument(
  45. 'repository', default=brew.DEFAULT_REPOSITORY,
  46. nargs='?', help='git repository containing the library definition'
  47. ' files. Default is ' + brew.DEFAULT_REPOSITORY
  48. )
  49. # parser.add_argument(
  50. # '--reg', default=None, help='Registry address to'
  51. # ' push build results to. Also sets push to true.'
  52. # )
  53. parser.add_argument(
  54. '--targets', default=None, help='Comma-separated list'
  55. ' of images to build.'
  56. )
  57. args = parser.parse_args()
  58. if args.debug:
  59. brew.set_loglevel('DEBUG')
  60. namespaces = args.n.split(',')
  61. if args.no_namespace:
  62. namespaces.append('')
  63. targets = args.targets.split(',')
  64. sb_library = brew.StackbrewLibrary(args.repository, args.b)
  65. builder = brew.LocalBuilder(sb_library, namespaces, targets)
  66. builder.build_repo_list()
  67. builder.build_all()
  68. if args.push:
  69. builder.push_all()
  70. # summary = brew.build_library(
  71. # args.repository, args.b, args.n, args.push or args.reg is not None,
  72. # args.debug, args.prefill, args.reg, args.targets, None, logger
  73. # )