 
     definition = YAML.load def
 
+
     Instances.upsert {name: instance}, $set:
       images: (service.image for serviceName, service of definition)
       compose: definition

    # though Docker events and inspect information.
    # This way we can relate containers and events
    for serviceName, service of definition
      service.labels =
        'bigboat/instance/name': instance
        'bigboat/service/name': serviceName
        'bigboat/container/type': 'service'
        'bigboat/application/name': app
        'bigboat/application/version': version
        'bigboat/agent/url': agentUrl
        'bigboat/startedBy': user._id
        'bigboat/storage/bucket': options.storageBucket
        'bigboat/instance/endpoint': bigboatCompose[serviceName]?.endpoint
        'bigboat/instance/endpoint/protocol': bigboatCompose[serviceName]?.protocol
      service.restart = 'unless-stopped'

    console.log 'xxx', definition

    callOpts =
      responseType: "buffer"
      data:
        dir: dir

        app:
          name: app
          version: version
          definition: definition
          bigboatCompose: bigboatCompose
          parameter_key: '_#_'
        instance:
          name: instance
          options: _.extend({}, options, { project: project })
          parameters: parameters
        bigboat:
          url: process.env.ROOT_URL
          statusUrl: "#{process.env.ROOT_URL}/api/v1/state/#{instance}"

      throw new Meteor.Error "Application #{app}:#{version} does not exist"

    project = Settings.get('project')

    options.storageBucket =
      if bucket = options.storageBucket
