2020-07-24 12:25:46 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2016-2020 Balena Ltd.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2023-09-06 14:39:31 +00:00
|
|
|
import { Flags, Args } from '@oclif/core';
|
|
|
|
import type { Interfaces } from '@oclif/core';
|
2023-11-07 22:32:25 +00:00
|
|
|
import Command from '../../command';
|
|
|
|
import * as cf from '../../utils/common-flags';
|
|
|
|
import { getBalenaSdk, stripIndent } from '../../utils/lazy';
|
|
|
|
import { dockerignoreHelp, registrySecretsHelp } from '../../utils/messages';
|
2021-02-04 06:41:49 +00:00
|
|
|
import type { BalenaSDK } from 'balena-sdk';
|
2023-11-07 22:32:25 +00:00
|
|
|
import { ExpectedError, instanceOf } from '../../errors';
|
2022-06-28 12:22:42 +00:00
|
|
|
import { RegistrySecrets } from '@balena/compose/dist/multibuild';
|
2023-11-07 22:32:25 +00:00
|
|
|
import { lowercaseIfSlug } from '../../utils/normalization';
|
2021-01-13 13:12:38 +00:00
|
|
|
import {
|
|
|
|
applyReleaseTagKeysAndValues,
|
|
|
|
parseReleaseTagKeysAndValues,
|
2023-11-07 22:32:25 +00:00
|
|
|
} from '../../utils/compose_ts';
|
2020-07-24 12:25:46 +00:00
|
|
|
|
|
|
|
enum BuildTarget {
|
|
|
|
Cloud,
|
|
|
|
Device,
|
|
|
|
}
|
|
|
|
|
2023-09-06 14:39:31 +00:00
|
|
|
type FlagsDef = Interfaces.InferredFlags<typeof PushCmd.flags>;
|
2020-07-24 12:25:46 +00:00
|
|
|
|
|
|
|
export default class PushCmd extends Command {
|
|
|
|
public static description = stripIndent`
|
2021-07-15 13:41:38 +00:00
|
|
|
Build release images on balenaCloud servers or on a local mode device.
|
2020-07-24 12:25:46 +00:00
|
|
|
|
2021-07-15 13:41:38 +00:00
|
|
|
Build release images on balenaCloud servers or on a local mode device.
|
2020-07-24 12:25:46 +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.
|
|
|
|
|
|
|
|
When building on a local mode device, the given source directory will be
|
|
|
|
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/
|
|
|
|
Note that local mode requires a supervisor version of at least v7.21.0.
|
|
|
|
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.
|
|
|
|
|
|
|
|
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
|
|
|
|
containers. The synchronization is only in one direction, from this machine to
|
|
|
|
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.
|
|
|
|
|
|
|
|
${registrySecretsHelp.split('\n').join('\n\t\t')}
|
|
|
|
|
|
|
|
${dockerignoreHelp.split('\n').join('\n\t\t')}
|
|
|
|
|
2021-07-15 13:41:38 +00:00
|
|
|
Note: the --service and --env flags must come after the fleetOrDevice
|
2020-09-08 14:30:41 +00:00
|
|
|
parameter, as per examples.
|
2020-07-24 12:25:46 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
public static examples = [
|
2021-07-15 13:41:38 +00:00
|
|
|
'$ balena push myFleet',
|
|
|
|
'$ balena push myFleet --source <source directory>',
|
|
|
|
'$ balena push myFleet -s <source directory>',
|
2022-07-14 19:40:59 +00:00
|
|
|
'$ balena push myFleet --source <source directory> --note "this is the note for this release"',
|
2021-07-15 13:41:38 +00:00
|
|
|
'$ balena push myFleet --release-tag key1 "" key2 "value2 with spaces"',
|
|
|
|
'$ balena push myorg/myfleet',
|
2020-07-24 12:25:46 +00:00
|
|
|
'',
|
|
|
|
'$ balena push 10.0.0.1',
|
|
|
|
'$ balena push 10.0.0.1 --source <source directory>',
|
|
|
|
'$ balena push 10.0.0.1 --service my-service',
|
|
|
|
'$ balena push 10.0.0.1 --env MY_ENV_VAR=value --env my-service:SERVICE_VAR=value',
|
|
|
|
'$ balena push 10.0.0.1 --nolive',
|
|
|
|
'',
|
|
|
|
'$ balena push 23c73a1.local --system',
|
|
|
|
'$ balena push 23c73a1.local --system --service my-service',
|
|
|
|
];
|
|
|
|
|
2023-09-06 14:39:31 +00:00
|
|
|
public static args = {
|
|
|
|
fleetOrDevice: Args.string({
|
2020-12-18 15:56:47 +00:00
|
|
|
description:
|
2021-07-15 13:41:38 +00:00
|
|
|
'fleet name or slug, or local device IP address or ".local" hostname',
|
2020-07-24 12:25:46 +00:00
|
|
|
required: true,
|
2020-12-18 15:56:47 +00:00
|
|
|
parse: lowercaseIfSlug,
|
2023-09-06 14:39:31 +00:00
|
|
|
}),
|
|
|
|
};
|
2020-07-24 12:25:46 +00:00
|
|
|
|
2021-07-15 13:41:38 +00:00
|
|
|
public static usage = 'push <fleetOrDevice>';
|
2020-07-24 12:25:46 +00:00
|
|
|
|
2023-09-06 14:39:31 +00:00
|
|
|
public static flags = {
|
|
|
|
source: Flags.string({
|
2020-09-08 14:30:41 +00:00
|
|
|
description: stripIndent`
|
|
|
|
Source directory to be sent to balenaCloud or balenaOS device
|
|
|
|
(default: current working dir)`,
|
2020-07-24 12:25:46 +00:00
|
|
|
char: 's',
|
2020-12-18 15:56:47 +00:00
|
|
|
default: '.',
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
emulated: Flags.boolean({
|
2020-10-01 23:10:40 +00:00
|
|
|
description: stripIndent`
|
2021-02-23 12:56:59 +00:00
|
|
|
Don't use the faster, native balenaCloud ARM builders; force slower QEMU ARM
|
|
|
|
emulation on Intel x86-64 builders. This flag is sometimes used to investigate
|
|
|
|
suspected issues with the balenaCloud backend.`,
|
2020-10-01 23:10:40 +00:00
|
|
|
char: 'e',
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
dockerfile: Flags.string({
|
2020-07-24 12:25:46 +00:00
|
|
|
description:
|
|
|
|
'Alternative Dockerfile name/path, relative to the source folder',
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
nocache: Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
2020-09-08 14:30:41 +00:00
|
|
|
Don't use cached layers of previously built images for this project. This
|
|
|
|
ensures that the latest base image and packages are pulled. Note that build
|
|
|
|
logs may still display the message _"Pulling previous images for caching
|
|
|
|
purposes" (as the cloud builder needs previous images to compute delta
|
|
|
|
updates), but the logs will not display the "Using cache" lines for each
|
|
|
|
build step of a Dockerfile.`,
|
2020-07-24 12:25:46 +00:00
|
|
|
char: 'c',
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
pull: Flags.boolean({
|
2020-09-08 13:55:56 +00:00
|
|
|
description: stripIndent`
|
|
|
|
When pushing to a local device, force the base images to be pulled again.
|
|
|
|
Currently this option is ignored when pushing to the balenaCloud builders.`,
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-09-08 13:55:56 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
'noparent-check': Flags.boolean({
|
2020-09-08 14:30:41 +00:00
|
|
|
description: stripIndent`
|
|
|
|
Disable project validation check of 'docker-compose.yml' file in parent folder`,
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
'registry-secrets': Flags.string({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
2020-09-08 14:30:41 +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)`,
|
2020-07-24 12:25:46 +00:00
|
|
|
char: 'R',
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
nolive: Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
2020-09-08 14:30:41 +00:00
|
|
|
Don't run a live session on this push. The filesystem will not be monitored,
|
|
|
|
and changes will not be synchronized to any running containers. Note that both
|
2023-01-13 04:36:38 +00:00
|
|
|
this flag and --detached are required to cause the process to end once the
|
2020-09-08 14:30:41 +00:00
|
|
|
initial build has completed.`,
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
detached: Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
2020-09-08 14:30:41 +00:00
|
|
|
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
|
2021-07-15 13:41:38 +00:00
|
|
|
the command to not tail logs when the build has completed.`,
|
2020-07-24 12:25:46 +00:00
|
|
|
char: 'd',
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
service: Flags.string({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
|
|
|
Reject logs not originating from this service.
|
|
|
|
This can be used in combination with --system and other --service flags.
|
|
|
|
Only valid when pushing to a local mode device.`,
|
|
|
|
multiple: true,
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
system: Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: stripIndent`
|
|
|
|
Only show system logs. This can be used in combination with --service.
|
|
|
|
Only valid when pushing to a local mode device.`,
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
env: Flags.string({
|
2020-07-24 12:25:46 +00:00
|
|
|
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.
|
|
|
|
`,
|
|
|
|
multiple: true,
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
'noconvert-eol': Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description: `Don't convert line endings from CRLF (Windows format) to LF (Unix format).`,
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
'multi-dockerignore': Flags.boolean({
|
2020-07-24 12:25:46 +00:00
|
|
|
description:
|
|
|
|
'Have each service use its own .dockerignore file. See "balena help push".',
|
|
|
|
char: 'm',
|
2020-12-18 15:56:47 +00:00
|
|
|
default: false,
|
2020-07-24 12:25:46 +00:00
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
'release-tag': Flags.string({
|
2020-12-16 14:42:25 +00:00
|
|
|
description: stripIndent`
|
2021-07-15 13:41:38 +00:00
|
|
|
Set release tags if the image build is successful (balenaCloud only). Multiple
|
2020-12-16 14:42:25 +00:00
|
|
|
arguments may be provided, alternating tag keys and values (see examples).
|
|
|
|
Hint: Empty values may be specified with "" (bash, cmd.exe) or '""' (PowerShell).
|
|
|
|
`,
|
|
|
|
multiple: true,
|
|
|
|
exclusive: ['detached'],
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
draft: Flags.boolean({
|
2021-05-19 15:06:45 +00:00
|
|
|
description: stripIndent`
|
|
|
|
Instruct the builder to create the release as a draft. Draft releases are ignored
|
|
|
|
by the 'track latest' release policy but can be used through release pinning.
|
|
|
|
Draft releases can be marked as final through the API. Releases are created
|
|
|
|
as final by default unless this option is given.`,
|
|
|
|
default: false,
|
|
|
|
}),
|
2023-09-06 14:39:31 +00:00
|
|
|
note: Flags.string({ description: 'The notes for this release' }),
|
2020-07-24 12:25:46 +00:00
|
|
|
help: cf.help,
|
|
|
|
};
|
|
|
|
|
|
|
|
public static primary = true;
|
|
|
|
|
|
|
|
public async run() {
|
2023-09-06 14:39:31 +00:00
|
|
|
const { args: params, flags: options } = await this.parse(PushCmd);
|
2020-07-24 12:25:46 +00:00
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
const logger = await Command.getLogger();
|
|
|
|
logger.logDebug(`Using build source directory: ${options.source} `);
|
|
|
|
|
2020-07-24 12:25:46 +00:00
|
|
|
const sdk = getBalenaSdk();
|
2023-11-07 22:32:25 +00:00
|
|
|
const { validateProjectDirectory } = await import('../../utils/compose_ts');
|
2020-07-24 12:25:46 +00:00
|
|
|
const { dockerfilePath, registrySecrets } = await validateProjectDirectory(
|
|
|
|
sdk,
|
|
|
|
{
|
|
|
|
dockerfilePath: options.dockerfile,
|
2020-12-18 15:56:47 +00:00
|
|
|
noParentCheck: options['noparent-check'],
|
|
|
|
projectPath: options.source,
|
2020-07-24 12:25:46 +00:00
|
|
|
registrySecretsPath: options['registry-secrets'],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2021-07-15 13:41:38 +00:00
|
|
|
switch (await this.getBuildTarget(params.fleetOrDevice)) {
|
2020-07-24 12:25:46 +00:00
|
|
|
case BuildTarget.Cloud:
|
2021-07-15 13:41:38 +00:00
|
|
|
logger.logDebug(`Pushing to cloud for fleet: ${params.fleetOrDevice}`);
|
2020-12-18 15:56:47 +00:00
|
|
|
|
2020-12-16 14:42:25 +00:00
|
|
|
await this.pushToCloud(
|
2021-07-15 13:41:38 +00:00
|
|
|
params.fleetOrDevice,
|
2020-12-16 14:42:25 +00:00
|
|
|
options,
|
|
|
|
sdk,
|
2020-07-24 12:25:46 +00:00
|
|
|
dockerfilePath,
|
|
|
|
registrySecrets,
|
2020-12-16 14:42:25 +00:00
|
|
|
);
|
2020-07-24 12:25:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BuildTarget.Device:
|
2021-07-15 13:41:38 +00:00
|
|
|
logger.logDebug(`Pushing to local device: ${params.fleetOrDevice}`);
|
2020-12-16 14:42:25 +00:00
|
|
|
await this.pushToDevice(
|
2021-07-15 13:41:38 +00:00
|
|
|
params.fleetOrDevice,
|
2020-12-16 14:42:25 +00:00
|
|
|
options,
|
|
|
|
dockerfilePath,
|
|
|
|
registrySecrets,
|
|
|
|
);
|
2020-07-24 12:25:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
protected async pushToCloud(
|
|
|
|
appNameOrSlug: string,
|
2020-12-16 14:42:25 +00:00
|
|
|
options: FlagsDef,
|
|
|
|
sdk: BalenaSDK,
|
|
|
|
dockerfilePath: string,
|
|
|
|
registrySecrets: RegistrySecrets,
|
|
|
|
) {
|
2023-11-07 22:32:25 +00:00
|
|
|
const remote = await import('../../utils/remote-build');
|
|
|
|
const { getApplication } = await import('../../utils/sdk');
|
2020-12-16 14:42:25 +00:00
|
|
|
|
|
|
|
// Check for invalid options
|
|
|
|
const localOnlyOptions: Array<keyof FlagsDef> = [
|
|
|
|
'nolive',
|
|
|
|
'service',
|
|
|
|
'system',
|
|
|
|
'env',
|
|
|
|
];
|
|
|
|
this.checkInvalidOptions(
|
|
|
|
localOnlyOptions,
|
|
|
|
options,
|
|
|
|
'is only valid when pushing to a local mode device',
|
|
|
|
);
|
|
|
|
|
2021-01-13 13:12:38 +00:00
|
|
|
const { releaseTagKeys, releaseTagValues } = parseReleaseTagKeysAndValues(
|
|
|
|
options['release-tag'] ?? [],
|
|
|
|
);
|
2020-12-16 14:42:25 +00:00
|
|
|
|
|
|
|
await Command.checkLoggedIn();
|
2020-12-18 15:56:47 +00:00
|
|
|
const [token, baseUrl] = await Promise.all([
|
2020-12-16 14:42:25 +00:00
|
|
|
sdk.auth.getToken(),
|
|
|
|
sdk.settings.get('balenaUrl'),
|
|
|
|
]);
|
|
|
|
|
2021-02-04 06:41:49 +00:00
|
|
|
const application = await getApplication(sdk, appNameOrSlug, {
|
2023-05-19 21:21:16 +00:00
|
|
|
$select: 'slug',
|
2021-02-04 06:41:49 +00:00
|
|
|
});
|
2021-01-15 16:47:39 +00:00
|
|
|
|
2020-12-16 14:42:25 +00:00
|
|
|
const opts = {
|
|
|
|
dockerfilePath,
|
2020-12-18 15:56:47 +00:00
|
|
|
emulated: options.emulated,
|
|
|
|
multiDockerignore: options['multi-dockerignore'],
|
|
|
|
nocache: options.nocache,
|
2020-12-16 14:42:25 +00:00
|
|
|
registrySecrets,
|
2020-12-18 15:56:47 +00:00
|
|
|
headless: options.detached,
|
|
|
|
convertEol: !options['noconvert-eol'],
|
2021-05-19 15:06:45 +00:00
|
|
|
isDraft: options.draft,
|
2020-12-16 14:42:25 +00:00
|
|
|
};
|
|
|
|
const args = {
|
2021-02-04 06:41:49 +00:00
|
|
|
appSlug: application.slug,
|
2020-12-18 15:56:47 +00:00
|
|
|
source: options.source,
|
2020-12-16 14:42:25 +00:00
|
|
|
auth: token,
|
|
|
|
baseUrl,
|
|
|
|
sdk,
|
|
|
|
opts,
|
|
|
|
};
|
|
|
|
const releaseId = await remote.startRemoteBuild(args);
|
|
|
|
if (releaseId) {
|
2021-01-13 13:12:38 +00:00
|
|
|
await applyReleaseTagKeysAndValues(
|
|
|
|
sdk,
|
|
|
|
releaseId,
|
|
|
|
releaseTagKeys,
|
|
|
|
releaseTagValues,
|
2020-12-16 14:42:25 +00:00
|
|
|
);
|
2022-07-14 19:40:59 +00:00
|
|
|
if (options.note) {
|
2023-05-23 10:21:51 +00:00
|
|
|
await sdk.models.release.setNote(releaseId, options.note);
|
2022-07-14 19:40:59 +00:00
|
|
|
}
|
2020-12-16 14:42:25 +00:00
|
|
|
} else if (releaseTagKeys.length > 0) {
|
|
|
|
throw new Error(stripIndent`
|
|
|
|
A release ID could not be parsed out of the builder's output.
|
|
|
|
As a result, the release tags have not been set.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
protected async pushToDevice(
|
|
|
|
localDeviceAddress: string,
|
2020-12-16 14:42:25 +00:00
|
|
|
options: FlagsDef,
|
|
|
|
dockerfilePath: string,
|
|
|
|
registrySecrets: RegistrySecrets,
|
|
|
|
) {
|
|
|
|
// Check for invalid options
|
2021-05-19 15:06:45 +00:00
|
|
|
const remoteOnlyOptions: Array<keyof FlagsDef> = ['release-tag', 'draft'];
|
2020-12-16 14:42:25 +00:00
|
|
|
this.checkInvalidOptions(
|
|
|
|
remoteOnlyOptions,
|
|
|
|
options,
|
2021-07-15 13:41:38 +00:00
|
|
|
'is only valid when pushing to a fleet',
|
2020-12-16 14:42:25 +00:00
|
|
|
);
|
|
|
|
|
2023-11-07 22:32:25 +00:00
|
|
|
const deviceDeploy = await import('../../utils/device/deploy');
|
2020-12-16 14:42:25 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
await deviceDeploy.deployToDevice({
|
2020-12-18 15:56:47 +00:00
|
|
|
source: options.source,
|
|
|
|
deviceHost: localDeviceAddress,
|
2020-12-16 14:42:25 +00:00
|
|
|
dockerfilePath,
|
|
|
|
registrySecrets,
|
2020-12-18 15:56:47 +00:00
|
|
|
multiDockerignore: options['multi-dockerignore'],
|
|
|
|
nocache: options.nocache,
|
|
|
|
pull: options.pull,
|
|
|
|
noParentCheck: options['noparent-check'],
|
|
|
|
nolive: options.nolive,
|
|
|
|
detached: options.detached,
|
|
|
|
services: options.service,
|
|
|
|
system: options.system,
|
2020-12-16 14:42:25 +00:00
|
|
|
env: options.env || [],
|
2020-12-18 15:56:47 +00:00
|
|
|
convertEol: !options['noconvert-eol'],
|
2020-12-16 14:42:25 +00:00
|
|
|
});
|
|
|
|
} catch (e) {
|
2023-11-07 22:32:25 +00:00
|
|
|
const { BuildError } = await import('../../utils/device/errors');
|
2020-12-16 14:42:25 +00:00
|
|
|
if (instanceOf(e, BuildError)) {
|
|
|
|
throw new ExpectedError(e.toString());
|
|
|
|
} else {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
protected async getBuildTarget(appOrDevice: string): Promise<BuildTarget> {
|
2023-11-07 22:32:25 +00:00
|
|
|
const { validateLocalHostnameOrIp } = await import(
|
|
|
|
'../../utils/validation'
|
|
|
|
);
|
2020-07-24 12:25:46 +00:00
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
return validateLocalHostnameOrIp(appOrDevice)
|
|
|
|
? BuildTarget.Device
|
|
|
|
: BuildTarget.Cloud;
|
2020-07-24 12:25:46 +00:00
|
|
|
}
|
2020-12-16 14:42:25 +00:00
|
|
|
|
2020-12-18 15:56:47 +00:00
|
|
|
protected checkInvalidOptions(
|
2020-12-16 14:42:25 +00:00
|
|
|
invalidOptions: Array<keyof FlagsDef>,
|
|
|
|
options: FlagsDef,
|
|
|
|
errorMessage: string,
|
|
|
|
) {
|
|
|
|
invalidOptions.forEach((opt) => {
|
|
|
|
if (options[opt]) {
|
|
|
|
throw new ExpectedError(`The --${opt} flag ${errorMessage}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-07-24 12:25:46 +00:00
|
|
|
}
|