2018-04-25 14:20:07 +00:00
|
|
|
/*
|
2020-01-29 11:10:59 +00:00
|
|
|
Copyright 2016-2020 Balena Ltd.
|
2018-04-25 14:20:07 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-03-12 22:07:57 +00:00
|
|
|
import { BalenaSDK } from 'balena-sdk';
|
2018-04-25 14:20:07 +00:00
|
|
|
import { CommandDefinition } from 'capitano';
|
|
|
|
import { stripIndent } from 'common-tags';
|
2018-10-16 10:25:37 +00:00
|
|
|
|
2020-02-15 20:38:20 +00:00
|
|
|
import { ExpectedError } from '../errors';
|
2020-02-27 14:55:30 +00:00
|
|
|
import { getBalenaSdk } from '../utils/lazy';
|
2020-05-01 11:18:11 +00:00
|
|
|
import { dockerignoreHelp, registrySecretsHelp } from '../utils/messages';
|
2019-04-24 09:06:53 +00:00
|
|
|
import {
|
|
|
|
validateApplicationName,
|
2019-04-24 16:47:08 +00:00
|
|
|
validateDotLocalUrl,
|
2019-04-24 09:06:53 +00:00
|
|
|
validateIPAddress,
|
|
|
|
} from '../utils/validation';
|
2020-05-28 17:03:40 +00:00
|
|
|
import { isV12 } from '../utils/version';
|
2018-10-16 10:25:37 +00:00
|
|
|
|
|
|
|
enum BuildTarget {
|
|
|
|
Cloud,
|
|
|
|
Device,
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBuildTarget(appOrDevice: string): BuildTarget | null {
|
|
|
|
// First try the application regex from the api
|
2019-04-24 09:06:53 +00:00
|
|
|
if (validateApplicationName(appOrDevice)) {
|
2018-10-16 10:25:37 +00:00
|
|
|
return BuildTarget.Cloud;
|
|
|
|
}
|
|
|
|
|
2019-04-24 16:47:08 +00:00
|
|
|
if (validateIPAddress(appOrDevice) || validateDotLocalUrl(appOrDevice)) {
|
2018-10-16 10:25:37 +00:00
|
|
|
return BuildTarget.Device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-25 14:20:07 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
async function getAppOwner(sdk: BalenaSDK, appName: string) {
|
2020-02-15 20:38:20 +00:00
|
|
|
const { selectFromList } = await import('../utils/patterns');
|
2018-04-25 14:20:07 +00:00
|
|
|
const _ = await import('lodash');
|
|
|
|
|
|
|
|
const applications = await sdk.models.application.getAll({
|
|
|
|
$expand: {
|
|
|
|
user: {
|
|
|
|
$select: ['username'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
$filter: {
|
2018-11-15 09:26:25 +00:00
|
|
|
$eq: [{ $tolower: { $: 'app_name' } }, appName.toLowerCase()],
|
2018-04-25 14:20:07 +00:00
|
|
|
},
|
|
|
|
$select: ['id'],
|
|
|
|
});
|
|
|
|
|
|
|
|
if (applications == null || applications.length === 0) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2018-04-25 14:20:07 +00:00
|
|
|
stripIndent`
|
|
|
|
No applications found with name: ${appName}.
|
|
|
|
|
|
|
|
This could mean that the application does not exist, or you do
|
|
|
|
not have the permissions required to access it.`,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (applications.length === 1) {
|
|
|
|
return _.get(applications, '[0].user[0].username');
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we got more than one application with the same name it means that the
|
|
|
|
// user has access to a collab app with the same name as a personal app. We
|
|
|
|
// present a list to the user which shows the fully qualified application
|
|
|
|
// name (user/appname) and allows them to select
|
2020-06-15 22:53:07 +00:00
|
|
|
const entries = _.map(applications, (app) => {
|
2018-04-25 14:20:07 +00:00
|
|
|
const username = _.get(app, 'user[0].username');
|
|
|
|
return {
|
|
|
|
name: `${username}/${appName}`,
|
|
|
|
extra: username,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const selected = await selectFromList(
|
2020-01-20 21:21:05 +00:00
|
|
|
`${entries.length} applications found with that name, please select the application you would like to push to`,
|
2018-04-25 14:20:07 +00:00
|
|
|
entries,
|
|
|
|
);
|
|
|
|
|
|
|
|
return selected.extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const push: CommandDefinition<
|
|
|
|
{
|
2019-04-26 23:50:37 +00:00
|
|
|
// when Capitano converts a positional parameter (but not an option)
|
|
|
|
// to a number, the original value is preserved with the _raw suffix
|
2018-10-16 10:25:37 +00:00
|
|
|
applicationOrDevice: string;
|
2019-04-26 23:50:37 +00:00
|
|
|
applicationOrDevice_raw: string;
|
2018-04-25 14:20:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-05-28 15:56:39 +00:00
|
|
|
source?: string;
|
|
|
|
emulated?: boolean;
|
|
|
|
dockerfile?: string; // DeviceDeployOptions.dockerfilePath (alternative Dockerfile)
|
|
|
|
nocache?: boolean;
|
2020-02-15 20:20:56 +00:00
|
|
|
'noparent-check'?: boolean;
|
2019-05-28 15:56:39 +00:00
|
|
|
'registry-secrets'?: string;
|
2020-06-16 23:38:03 +00:00
|
|
|
gitignore?: boolean;
|
2020-05-01 11:18:11 +00:00
|
|
|
nogitignore?: boolean;
|
2019-05-29 14:09:05 +00:00
|
|
|
nolive?: boolean;
|
2019-05-28 15:56:39 +00:00
|
|
|
detached?: boolean;
|
|
|
|
service?: string | string[];
|
|
|
|
system?: boolean;
|
|
|
|
env?: string | string[];
|
2020-01-29 11:10:59 +00:00
|
|
|
'convert-eol'?: boolean;
|
2020-06-03 13:41:12 +00:00
|
|
|
'noconvert-eol'?: boolean;
|
2018-04-25 14:20:07 +00:00
|
|
|
}
|
|
|
|
> = {
|
2018-10-16 10:25:37 +00:00
|
|
|
signature: 'push <applicationOrDevice>',
|
2019-04-02 17:01:28 +00:00
|
|
|
primary: true,
|
2018-10-16 10:25:37 +00:00
|
|
|
description:
|
2018-10-19 14:38:50 +00:00
|
|
|
'Start a remote build on the balena cloud build servers or a local mode device',
|
2018-04-25 14:20:07 +00:00
|
|
|
help: stripIndent`
|
2019-01-16 19:54:46 +00:00
|
|
|
This command can be used to start a build on the remote balena cloud builders,
|
|
|
|
or a local mode balena device.
|
|
|
|
|
2019-02-27 18:01:47 +00:00
|
|
|
When building on the balenaCloud servers, the given source directory will be
|
|
|
|
sent to the remote server. This can be used as a drop-in replacement for the
|
|
|
|
"git push" deployment method.
|
2018-11-07 18:15:05 +00:00
|
|
|
|
2019-04-23 10:38:13 +00:00
|
|
|
When building on a local mode device, the given source directory will be
|
2019-02-27 18:01:47 +00:00
|
|
|
built on the device, and the resulting containers will be run on the device.
|
|
|
|
Logs will be streamed back from the device as part of the same invocation.
|
|
|
|
The web dashboard can be used to switch a device to local mode:
|
|
|
|
https://www.balena.io/docs/learn/develop/local-mode/
|
2019-04-23 10:38:13 +00:00
|
|
|
Note that local mode requires a supervisor version of at least v7.21.0.
|
2019-04-24 16:30:18 +00:00
|
|
|
The logs from only a single service can be shown with the --service flag, and
|
|
|
|
showing only the system logs can be achieved with --system. Note that these
|
|
|
|
flags can be used together.
|
2019-04-23 10:38:13 +00:00
|
|
|
|
2019-05-29 14:09:05 +00:00
|
|
|
When pushing to a local device a live session will be started.
|
|
|
|
The project source folder is watched for filesystem events, and changes
|
|
|
|
to files and folders are automatically synchronized to the running
|
2020-01-03 18:37:55 +00:00
|
|
|
containers. The synchronization is only in one direction, from this machine to
|
2019-05-29 14:09:05 +00:00
|
|
|
the device, and changes made on the device itself may be overwritten.
|
|
|
|
This feature requires a device running supervisor version v9.7.0 or greater.
|
2018-11-07 18:15:05 +00:00
|
|
|
|
2019-02-27 18:01:47 +00:00
|
|
|
${registrySecretsHelp.split('\n').join('\n\t\t')}
|
2018-10-16 10:25:37 +00:00
|
|
|
|
2020-05-01 11:18:11 +00:00
|
|
|
${dockerignoreHelp.split('\n').join('\n\t\t')}
|
|
|
|
|
2018-04-25 14:20:07 +00:00
|
|
|
Examples:
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ balena push myApp
|
|
|
|
$ balena push myApp --source <source directory>
|
|
|
|
$ balena push myApp -s <source directory>
|
2018-10-16 10:25:37 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ balena push 10.0.0.1
|
|
|
|
$ balena push 10.0.0.1 --source <source directory>
|
2019-04-24 13:59:07 +00:00
|
|
|
$ balena push 10.0.0.1 --service my-service
|
2019-05-27 10:32:47 +00:00
|
|
|
$ balena push 10.0.0.1 --env MY_ENV_VAR=value --env my-service:SERVICE_VAR=value
|
2019-05-29 14:09:05 +00:00
|
|
|
$ balena push 10.0.0.1 --nolive
|
2019-04-24 16:47:08 +00:00
|
|
|
|
|
|
|
$ balena push 23c73a1.local --system
|
|
|
|
$ balena push 23c73a1.local --system --service my-service
|
2018-04-25 14:20:07 +00:00
|
|
|
`,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
signature: 'source',
|
|
|
|
alias: 's',
|
|
|
|
description:
|
2020-05-01 11:18:11 +00:00
|
|
|
'Source directory to be sent to balenaCloud or balenaOS device (default: current working dir)',
|
2018-04-25 14:20:07 +00:00
|
|
|
parameter: 'source',
|
|
|
|
},
|
2018-06-21 13:29:25 +00:00
|
|
|
{
|
|
|
|
signature: 'emulated',
|
|
|
|
alias: 'e',
|
|
|
|
description: 'Force an emulated build to occur on the remote builder',
|
|
|
|
boolean: true,
|
|
|
|
},
|
2019-04-11 11:49:19 +00:00
|
|
|
{
|
|
|
|
signature: 'dockerfile',
|
|
|
|
parameter: 'Dockerfile',
|
|
|
|
description:
|
|
|
|
'Alternative Dockerfile name/path, relative to the source folder',
|
|
|
|
},
|
2018-06-21 13:29:25 +00:00
|
|
|
{
|
|
|
|
signature: 'nocache',
|
|
|
|
alias: 'c',
|
|
|
|
description: "Don't use cache when building this project",
|
|
|
|
boolean: true,
|
|
|
|
},
|
2020-02-15 20:20:56 +00:00
|
|
|
{
|
|
|
|
signature: 'noparent-check',
|
|
|
|
description:
|
|
|
|
"Disable project validation check of 'docker-compose.yml' file in parent folder",
|
|
|
|
boolean: true,
|
|
|
|
},
|
2018-11-07 18:15:05 +00:00
|
|
|
{
|
|
|
|
signature: 'registry-secrets',
|
|
|
|
alias: 'R',
|
|
|
|
parameter: 'secrets.yml|.json',
|
|
|
|
description: stripIndent`
|
2019-06-18 10:13:09 +00:00
|
|
|
Path to a local YAML or JSON file containing Docker registry passwords used to pull base images.
|
|
|
|
Note that if registry-secrets are not provided on the command line, a secrets configuration
|
|
|
|
file from the balena directory will be used (usually $HOME/.balena/secrets.yml|.json)`,
|
2018-11-07 18:15:05 +00:00
|
|
|
},
|
2019-01-14 16:51:57 +00:00
|
|
|
{
|
2019-05-29 14:09:05 +00:00
|
|
|
signature: 'nolive',
|
2019-01-14 16:51:57 +00:00
|
|
|
boolean: true,
|
|
|
|
description: stripIndent`
|
2019-05-29 14:09:05 +00:00
|
|
|
Don't run a live session on this push. The filesystem will not be monitored, and changes
|
2020-01-03 18:37:55 +00:00
|
|
|
will not be synchronized to any running containers. Note that both this flag and --detached
|
2019-05-29 14:09:05 +00:00
|
|
|
and required to cause the process to end once the initial build has completed.`,
|
2019-01-14 16:51:57 +00:00
|
|
|
},
|
2019-04-24 13:31:30 +00:00
|
|
|
{
|
|
|
|
signature: 'detached',
|
|
|
|
alias: 'd',
|
2019-07-25 09:11:41 +00:00
|
|
|
description: stripIndent`
|
|
|
|
When pushing to the cloud, this option will cause the build to start, then return execution
|
|
|
|
back to the shell, with the status and release ID (if applicable).
|
|
|
|
|
|
|
|
When pushing to a local mode device, this option will cause the command to not tail application logs when the build
|
|
|
|
has completed.`,
|
2019-04-24 13:31:30 +00:00
|
|
|
boolean: true,
|
|
|
|
},
|
2019-04-24 13:59:07 +00:00
|
|
|
{
|
|
|
|
signature: 'service',
|
|
|
|
description: stripIndent`
|
2019-05-28 15:56:39 +00:00
|
|
|
Reject logs not originating from this service.
|
|
|
|
This can be used in combination with --system and other --service flags.
|
2019-04-24 13:59:07 +00:00
|
|
|
Only valid when pushing to a local mode device.`,
|
|
|
|
parameter: 'service',
|
|
|
|
},
|
2019-04-24 16:30:18 +00:00
|
|
|
{
|
|
|
|
signature: 'system',
|
|
|
|
description: stripIndent`
|
|
|
|
Only show system logs. This can be used in combination with --service.
|
|
|
|
Only valid when pushing to a local mode device.`,
|
|
|
|
boolean: true,
|
|
|
|
},
|
2019-05-27 10:32:47 +00:00
|
|
|
{
|
|
|
|
signature: 'env',
|
|
|
|
parameter: 'env',
|
|
|
|
description: stripIndent`
|
|
|
|
When performing a push to device, run the built containers with environment
|
|
|
|
variables provided with this argument. Environment variables can be applied
|
|
|
|
to individual services by adding their service name before the argument,
|
|
|
|
separated by a colon, e.g:
|
|
|
|
--env main:MY_ENV=value
|
|
|
|
Note that if the service name cannot be found in the composition, the entire
|
|
|
|
left hand side of the = character will be treated as the variable name.
|
|
|
|
`,
|
|
|
|
},
|
2020-01-29 11:10:59 +00:00
|
|
|
{
|
|
|
|
signature: 'convert-eol',
|
|
|
|
alias: 'l',
|
2020-06-03 13:41:12 +00:00
|
|
|
description: isV12()
|
|
|
|
? 'No-op and deprecated since balena CLI v12.0.0'
|
|
|
|
: stripIndent`
|
2020-02-07 13:22:20 +00:00
|
|
|
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format).
|
|
|
|
Source files are not modified.`,
|
2020-01-29 11:10:59 +00:00
|
|
|
boolean: true,
|
|
|
|
},
|
2020-06-03 13:41:12 +00:00
|
|
|
...(isV12()
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
signature: 'noconvert-eol',
|
|
|
|
description:
|
|
|
|
"Don't convert line endings from CRLF (Windows format) to LF (Unix format).",
|
|
|
|
boolean: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
2020-05-01 11:18:11 +00:00
|
|
|
{
|
|
|
|
signature: 'nogitignore',
|
|
|
|
alias: 'G',
|
2020-06-16 23:38:03 +00:00
|
|
|
description:
|
|
|
|
'No-op (default behavior) since balena CLI v12.0.0. See "balena help push".',
|
|
|
|
boolean: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
signature: 'gitignore',
|
|
|
|
alias: 'g',
|
|
|
|
description: stripIndent`
|
|
|
|
Consider .gitignore files in addition to the .dockerignore file. This reverts
|
|
|
|
to the CLI v11 behavior/implementation (deprecated) if compatibility is required
|
|
|
|
until your project can be adapted.`,
|
2020-05-01 11:18:11 +00:00
|
|
|
boolean: true,
|
|
|
|
},
|
2018-04-25 14:20:07 +00:00
|
|
|
],
|
2020-02-15 20:38:20 +00:00
|
|
|
async action(params, options) {
|
2020-02-27 14:55:30 +00:00
|
|
|
const sdk = getBalenaSdk();
|
2018-04-25 14:20:07 +00:00
|
|
|
const Bluebird = await import('bluebird');
|
|
|
|
const remote = await import('../utils/remote-build');
|
2018-10-16 10:25:37 +00:00
|
|
|
const deviceDeploy = await import('../utils/device/deploy');
|
2020-02-15 20:38:20 +00:00
|
|
|
const { checkLoggedIn } = await import('../utils/patterns');
|
2020-02-15 20:20:56 +00:00
|
|
|
const { validateProjectDirectory } = await import('../utils/compose_ts');
|
2019-02-26 13:32:27 +00:00
|
|
|
const { BuildError } = await import('../utils/device/errors');
|
2018-04-25 14:20:07 +00:00
|
|
|
|
2019-04-26 23:50:37 +00:00
|
|
|
const appOrDevice: string | null =
|
|
|
|
params.applicationOrDevice_raw || params.applicationOrDevice;
|
2018-10-16 10:25:37 +00:00
|
|
|
if (appOrDevice == null) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError('You must specify an application or a device');
|
2018-04-25 14:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const source = options.source || '.';
|
|
|
|
if (process.env.DEBUG) {
|
2019-09-18 12:13:35 +00:00
|
|
|
console.error(`[debug] Using ${source} as build source`);
|
2018-04-25 14:20:07 +00:00
|
|
|
}
|
|
|
|
|
2020-02-15 20:20:56 +00:00
|
|
|
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
|
2019-06-18 10:13:09 +00:00
|
|
|
sdk,
|
2020-02-15 20:20:56 +00:00
|
|
|
{
|
|
|
|
dockerfilePath: options.dockerfile,
|
|
|
|
noParentCheck: options['noparent-check'] || false,
|
|
|
|
projectPath: source,
|
|
|
|
registrySecretsPath: options['registry-secrets'],
|
|
|
|
},
|
2019-06-18 10:13:09 +00:00
|
|
|
);
|
2018-11-07 18:15:05 +00:00
|
|
|
|
2020-06-16 23:38:03 +00:00
|
|
|
const nogitignore = !options.gitignore;
|
2020-06-03 13:41:12 +00:00
|
|
|
const convertEol = isV12()
|
|
|
|
? !options['noconvert-eol']
|
|
|
|
: !!options['convert-eol'];
|
2020-05-28 17:03:40 +00:00
|
|
|
|
2018-10-16 10:25:37 +00:00
|
|
|
const buildTarget = getBuildTarget(appOrDevice);
|
|
|
|
switch (buildTarget) {
|
|
|
|
case BuildTarget.Cloud:
|
2019-01-14 16:51:57 +00:00
|
|
|
// Ensure that the live argument has not been passed to a cloud build
|
2019-05-29 14:09:05 +00:00
|
|
|
if (options.nolive != null) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2019-05-29 14:09:05 +00:00
|
|
|
'The --nolive flag is only valid when pushing to a local mode device',
|
2019-04-24 13:31:30 +00:00
|
|
|
);
|
|
|
|
}
|
2019-04-24 13:59:07 +00:00
|
|
|
if (options.service) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2019-04-24 13:59:07 +00:00
|
|
|
'The --service flag is only valid when pushing to a local mode device.',
|
|
|
|
);
|
|
|
|
}
|
2019-04-24 16:30:18 +00:00
|
|
|
if (options.system) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2019-04-24 16:30:18 +00:00
|
|
|
'The --system flag is only valid when pushing to a local mode device.',
|
|
|
|
);
|
|
|
|
}
|
2019-05-27 10:32:47 +00:00
|
|
|
if (options.env) {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2019-05-27 10:32:47 +00:00
|
|
|
'The --env flag is only valid when pushing to a local mode device.',
|
|
|
|
);
|
|
|
|
}
|
2019-01-14 16:51:57 +00:00
|
|
|
|
2018-10-16 10:25:37 +00:00
|
|
|
const app = appOrDevice;
|
2020-02-15 20:38:20 +00:00
|
|
|
await checkLoggedIn();
|
2019-03-04 15:06:31 +00:00
|
|
|
await Bluebird.join(
|
2018-10-16 10:25:37 +00:00
|
|
|
sdk.auth.getToken(),
|
2018-10-19 14:38:50 +00:00
|
|
|
sdk.settings.get('balenaUrl'),
|
2018-10-16 10:25:37 +00:00
|
|
|
getAppOwner(sdk, app),
|
2019-03-04 15:06:31 +00:00
|
|
|
async (token, baseUrl, owner) => {
|
2018-10-16 10:25:37 +00:00
|
|
|
const opts = {
|
2019-04-11 11:49:19 +00:00
|
|
|
dockerfilePath,
|
2019-05-28 15:56:39 +00:00
|
|
|
emulated: options.emulated || false,
|
|
|
|
nocache: options.nocache || false,
|
2018-11-07 18:15:05 +00:00
|
|
|
registrySecrets,
|
2019-07-25 09:11:41 +00:00
|
|
|
headless: options.detached || false,
|
2020-06-03 13:41:12 +00:00
|
|
|
convertEol,
|
2018-10-16 10:25:37 +00:00
|
|
|
};
|
|
|
|
const args = {
|
|
|
|
app,
|
|
|
|
owner,
|
|
|
|
source,
|
|
|
|
auth: token,
|
|
|
|
baseUrl,
|
2020-05-28 17:03:40 +00:00
|
|
|
nogitignore,
|
2018-10-16 10:25:37 +00:00
|
|
|
sdk,
|
|
|
|
opts,
|
|
|
|
};
|
2019-03-04 15:06:31 +00:00
|
|
|
return await remote.startRemoteBuild(args);
|
2018-10-16 10:25:37 +00:00
|
|
|
},
|
2020-02-15 20:38:20 +00:00
|
|
|
);
|
2018-10-16 10:25:37 +00:00
|
|
|
break;
|
|
|
|
case BuildTarget.Device:
|
|
|
|
const device = appOrDevice;
|
2019-05-28 15:56:39 +00:00
|
|
|
const servicesToDisplay =
|
|
|
|
options.service != null
|
2020-03-13 16:09:43 +00:00
|
|
|
? Array.isArray(options.service)
|
2019-05-28 15:56:39 +00:00
|
|
|
? options.service
|
|
|
|
: [options.service]
|
|
|
|
: undefined;
|
2018-10-16 10:25:37 +00:00
|
|
|
// TODO: Support passing a different port
|
2019-03-04 15:06:31 +00:00
|
|
|
await Bluebird.resolve(
|
2018-10-16 10:25:37 +00:00
|
|
|
deviceDeploy.deployToDevice({
|
|
|
|
source,
|
|
|
|
deviceHost: device,
|
2019-04-11 11:49:19 +00:00
|
|
|
dockerfilePath,
|
2018-11-07 18:15:05 +00:00
|
|
|
registrySecrets,
|
2019-03-28 12:20:08 +00:00
|
|
|
nocache: options.nocache || false,
|
2020-05-28 17:03:40 +00:00
|
|
|
nogitignore,
|
2020-02-15 20:20:56 +00:00
|
|
|
noParentCheck: options['noparent-check'] || false,
|
2019-05-29 14:09:05 +00:00
|
|
|
nolive: options.nolive || false,
|
2019-04-24 13:31:30 +00:00
|
|
|
detached: options.detached || false,
|
2019-05-28 15:56:39 +00:00
|
|
|
services: servicesToDisplay,
|
2019-04-24 16:30:18 +00:00
|
|
|
system: options.system || false,
|
2019-05-27 10:32:47 +00:00
|
|
|
env:
|
|
|
|
typeof options.env === 'string'
|
|
|
|
? [options.env]
|
|
|
|
: options.env || [],
|
2020-06-03 13:41:12 +00:00
|
|
|
convertEol,
|
2018-10-16 10:25:37 +00:00
|
|
|
}),
|
2020-06-15 22:53:07 +00:00
|
|
|
).catch(BuildError, (e) => {
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(e.toString());
|
|
|
|
});
|
2018-10-16 10:25:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-15 20:38:20 +00:00
|
|
|
throw new ExpectedError(
|
2018-10-16 10:25:37 +00:00
|
|
|
stripIndent`
|
2020-02-15 20:20:56 +00:00
|
|
|
Build target not recognized. Please provide either an application name or device address.
|
2018-10-16 10:25:37 +00:00
|
|
|
|
|
|
|
The only supported device addresses currently are IP addresses.
|
|
|
|
|
|
|
|
If you believe your build target should have been detected, and this is an error, please
|
|
|
|
create an issue.`,
|
|
|
|
);
|
|
|
|
}
|
2018-04-25 14:20:07 +00:00
|
|
|
},
|
|
|
|
};
|