code: func Detect(config backend.BuildConfig) (remote builder.Source, dockerfile *parser.Result, err error) {
  	remoteURL := config.Options.RemoteContext
  	dockerfilePath := config.Options.Dockerfile
  
  	switch {
  	case remoteURL == "":
  		remote, dockerfile, err = newArchiveRemote(config.Source, dockerfilePath)
  	case remoteURL == ClientSessionRemote:
  		res, err := parser.Parse(config.Source)
  		if err != nil {
  			return nil, nil, errdefs.InvalidParameter(err)
  		}
  
  		return nil, res, nil
  	case urlutil.IsGitURL(remoteURL):
  		remote, dockerfile, err = newGitRemote(remoteURL, dockerfilePath)
  	case urlutil.IsURL(remoteURL):
  		remote, dockerfile, err = newURLRemote(remoteURL, dockerfilePath, config.ProgressWriter.ProgressReaderFunc)
  	default:
  		err = fmt.Errorf("remoteURL (%s) could not be recognized as URL", remoteURL)
  	}
  	return
  }
docs: // Detect returns a context and dockerfile from remote location or local
  // archive.