<commit_before>var AppContainer = require('./app_container');
var AppImage = require('./app_image');
var BuildImage = require('./build_image');
var Container = require('../container');
var StepRunner = require('./step_runner');

var config = require('../config/build_container');
var server = require('../config/server');

var BuildProcess = module.exports = function(options) {
  this.app = options.app;
  this.input = options.input;
};

BuildProcess.prototype.execute = function(cb) {
  var container = Container.create(server);

  buildImage = new BuildImage(container, config, this.input, this.app);
  var buildImageRunner = new StepRunner(buildImage);

  var self = this;
  buildImageRunner.run(function(err) {
    if (err) return cb(err);
    var appImage = new AppImage(container, buildImage.name, self.app);
    var appImageRunner = new StepRunner(appImage);

    appImageRunner.run(function(err) {
      if (err) return cb(err);

      var appContainer = new AppContainer(container, appImage.name);
      var appContainerRunner = new StepRunner(appContainer);

      appContainerRunner.run(cb);
    });
  });
};<commit_msg>Changing host build process to use pipeworks.<commit_after>var pipeworks = require('pipeworks');

var AppContainer = require('./app_container');
var AppImage = require('./app_image');
var BuildImage = require('./build_image');
var Container = require('../container');
var StepRunner = require('./step_runner');

var config = require('../config/build_container');
var server = require('../config/server');

function Context() {
  this.buildImage = null;
  this.appImage = null;
}

var BuildProcess = module.exports = function(options) {
  this.app = options.app;
  this.input = options.input;
};

BuildProcess.prototype.execute = function(cb) {
  var pipeline = pipeworks();
  var container = Container.create(server);

  var self = this;

  pipeline
    .fit(function(context, next) {
      context.buildImage = new BuildImage(container, config, self.input, self.app);
      var buildImageRunner = new StepRunner(context.buildImage);

      buildImageRunner.run(function(err) {
        if (err) return cb(err);
        next(context);
      });
    })
    .fit(function(context, next) {
      context.appImage = new AppImage(container, context.buildImage.name, self.app);
      var appImageRunner = new StepRunner(context.appImage);

      appImageRunner.run(function(err) {
        if (err) return cb(err);
        next(context);
      })
    })
    .fit(function(context, next) {
      var appContainer = new AppContainer(container, context.appImage.name);
      var appContainerRunner = new StepRunner(appContainer);

      appContainerRunner.run(cb);
    })
    .flow(new Context());
};
{'fraction_non_alphanumeric': 0.14038956266078648, 'fraction_numerical': 0.0, 'mean_word_length': 3.931159420289855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6484021', 'n_tokens_mistral': 785, 'n_tokens_neox': 775, 'n_words': 182}