balena-cli/build/actions/build.js
Cameron Diver d3772386bf
Add ability to build and deploy image locally using resin-cli
Using `resin build` a user can now build an image on their own docker
daemon. The daemon can be accessed via a local socket, a remote host and
a remote host over a TLS socket. Project type resolution is supported.
Nocache and tagging of images is also supported.

Using `resin deploy` a user can now deploy an image to their fleet. The
image can either be built by `resin-cli`, plain Docker, or from a remote
source.

Change-type: minor
Signed-off-by: Cameron Diver <cameron@resin.io>
2017-04-23 14:31:45 +01:00

58 lines
2.1 KiB
JavaScript

// Generated by CoffeeScript 1.12.5
var Promise, dockerUtils, getBundleInfo;
Promise = require('bluebird');
dockerUtils = require('../utils/docker');
getBundleInfo = Promise.method(function(options) {
var helpers;
helpers = require('../utils/helpers');
if (options.application != null) {
return helpers.getAppInfo(options.application).then(function(app) {
return [app.arch, app.device_type];
});
} else if ((options.arch != null) && (options.deviceType != null)) {
return [options.arch, options.deviceType];
} else {
return void 0;
}
});
module.exports = {
signature: 'build [source]',
description: 'Build a container locally',
permission: 'user',
help: 'Use this command to build a container with a provided docker daemon.\n\nYou must provide either an application or a device-type/architecture\npair to use the resin Dockerfile pre-processor\n(e.g. Dockerfile.template -> Dockerfile).\n\nExamples:\n\n $ resin build\n $ resin build ./source/\n $ resin build --deviceType raspberrypi3 --arch armhf\n $ resin build --application MyApp ./source/\n $ resin build --docker \'/var/run/docker.sock\'\n $ resin build --dockerHost my.docker.host --dockerPort 2376 --ca ca.pem --key key.pem --cert cert.pem',
options: dockerUtils.appendOptions([
{
signature: 'arch',
parameter: 'arch',
description: 'The architecture to build for',
alias: 'A'
}, {
signature: 'devicetype',
parameter: 'deviceType',
description: 'The type of device this build is for',
alias: 'd'
}, {
signature: 'application',
parameter: 'application',
description: 'The target resin.io application this build is for',
alias: 'a'
}, {
signature: 'tag',
parameter: 'tag',
description: 'The alias to the generated image',
alias: 't'
}, {
signature: 'nocache',
description: "Don't use docker layer caching when building",
boolean: true
}
]),
action: function(params, options, done) {
return dockerUtils.runBuild(params, options, getBundleInfo).asCallback(done);
}
};