 JSONStream = require 'JSONStream'
 PlatformAPI = require 'resin-platform-api/request'
 
+REGISTRY_ENDPOINT = 'registry.resin.io'
+DOCKER_SOCKET = '/run/docker.sock'
 PLATFORM_ENDPOINT = url.resolve(process.env.API_ENDPOINT, '/ewa/')
 resinAPI = new PlatformAPI(PLATFORM_ENDPOINT)
 
-docker = Promise.promisifyAll(new Docker(socketPath: '/run/docker.sock'))
+docker = Promise.promisifyAll(new Docker(socketPath: DOCKER_SOCKET))
 # Hack dockerode to promisify internal classes' prototypes
 Promise.promisifyAll(docker.getImage().__proto__)
 Promise.promisifyAll(docker.getContainer().__proto__)

		options =
			method: 'POST'
			path: "/v1.8/images/create?fromImage=#{app.imageId}"
			socketPath: '/run/docker.sock'

		req = http.request options, (res) ->
			if res.headers['content-type'] is 'application/json'

			remoteApps = _.filter(remoteApps, 'commit')
			remoteApps = _.map remoteApps, (app) ->
				return {
					imageId: "#{REGISTRY_ENDPOINT}/#{path.basename(app.git_repository, '.git')}/#{app.commit}"
				}

			remoteApps = _.indexBy(remoteApps, 'imageId')
