code: func (bm *BuildManager) Build(ctx context.Context, config backend.BuildConfig) (*builder.Result, error) {
  	buildsTriggered.Inc()
  	if config.Options.Dockerfile == "" {
  		config.Options.Dockerfile = builder.DefaultDockerfileName
  	}
  
  	source, dockerfile, err := remotecontext.Detect(config)
  	if err != nil {
  		return nil, err
  	}
  	defer func() {
  		if source != nil {
  			if err := source.Close(); err != nil {
  				logrus.Debugf("[BUILDER] failed to remove temporary context: %v", err)
  			}
  		}
  	}()
  
  	ctx, cancel := context.WithCancel(ctx)
  	defer cancel()
  
  	if src, err := bm.initializeClientSession(ctx, cancel, config.Options); err != nil {
  		return nil, err
  	} else if src != nil {
  		source = src
  	}
  
  	builderOptions := builderOptions{
  		Options:        config.Options,
  		ProgressWriter: config.ProgressWriter,
  		Backend:        bm.backend,
  		PathCache:      bm.pathCache,
  		IDMapping:      bm.idMapping,
  	}
  	b, err := newBuilder(ctx, builderOptions)
  	if err != nil {
  		return nil, err
  	}
  	return b.build(source, dockerfile)
  }
docs: // Build starts a new build from a BuildConfig