mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-08 03:44:13 +00:00
Make livepush the default when pushing to a local device
Change-type: major Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
5da307f02e
commit
6696b1b5f7
@ -1375,9 +1375,12 @@ 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.
|
||||
|
||||
It is also possible to run a push to a local mode device in live mode.
|
||||
This will watch for changes in the source directory and perform an
|
||||
in-place build in the running containers [BETA].
|
||||
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 synchronisation 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.
|
||||
|
||||
The --registry-secrets option specifies a JSON or YAML file containing private
|
||||
Docker registry usernames and passwords to be used when pulling base images.
|
||||
@ -1403,6 +1406,7 @@ Examples:
|
||||
$ 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
|
||||
@ -1429,16 +1433,11 @@ Don't use cache when building this project
|
||||
|
||||
Path to a local YAML or JSON file containing Docker registry passwords used to pull base images
|
||||
|
||||
#### --live, -l
|
||||
#### --nolive
|
||||
|
||||
Note this feature is in beta.
|
||||
|
||||
Start a live session with the containers pushed to a local mode device.
|
||||
The project source folder is watched for filesystem events, and changes
|
||||
to files and folders are automatically synchronized to the running
|
||||
containers. The synchronisation 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.
|
||||
Don't run a live session on this push. The filesystem will not be monitored, and changes
|
||||
will not be synchronised to any running containers. Note that both this flag and --detached
|
||||
and required to cause the process to end once the initial build has completed.
|
||||
|
||||
#### --detached, -d
|
||||
|
||||
|
@ -110,7 +110,7 @@ export const push: CommandDefinition<
|
||||
dockerfile?: string; // DeviceDeployOptions.dockerfilePath (alternative Dockerfile)
|
||||
nocache?: boolean;
|
||||
'registry-secrets'?: string;
|
||||
live?: boolean;
|
||||
nolive?: boolean;
|
||||
detached?: boolean;
|
||||
service?: string | string[];
|
||||
system?: boolean;
|
||||
@ -139,9 +139,12 @@ export const push: CommandDefinition<
|
||||
showing only the system logs can be achieved with --system. Note that these
|
||||
flags can be used together.
|
||||
|
||||
It is also possible to run a push to a local mode device in live mode.
|
||||
This will watch for changes in the source directory and perform an
|
||||
in-place build in the running containers [BETA].
|
||||
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 synchronisation 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')}
|
||||
|
||||
@ -155,6 +158,7 @@ export const push: CommandDefinition<
|
||||
$ 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
|
||||
@ -193,18 +197,12 @@ export const push: CommandDefinition<
|
||||
Path to a local YAML or JSON file containing Docker registry passwords used to pull base images`,
|
||||
},
|
||||
{
|
||||
signature: 'live',
|
||||
alias: 'l',
|
||||
signature: 'nolive',
|
||||
boolean: true,
|
||||
description: stripIndent`
|
||||
Note this feature is in beta.
|
||||
|
||||
Start a live session with the containers pushed to a local mode device.
|
||||
The project source folder is watched for filesystem events, and changes
|
||||
to files and folders are automatically synchronized to the running
|
||||
containers. The synchronisation 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.`,
|
||||
Don't run a live session on this push. The filesystem will not be monitored, and changes
|
||||
will not be synchronised to any running containers. Note that both this flag and --detached
|
||||
and required to cause the process to end once the initial build has completed.`,
|
||||
},
|
||||
{
|
||||
signature: 'detached',
|
||||
@ -279,9 +277,9 @@ export const push: CommandDefinition<
|
||||
switch (buildTarget) {
|
||||
case BuildTarget.Cloud:
|
||||
// Ensure that the live argument has not been passed to a cloud build
|
||||
if (options.live) {
|
||||
if (options.nolive != null) {
|
||||
exitWithExpectedError(
|
||||
'The --live flag is only valid when pushing to a local mode device',
|
||||
'The --nolive flag is only valid when pushing to a local mode device',
|
||||
);
|
||||
}
|
||||
if (options.detached) {
|
||||
@ -348,7 +346,7 @@ export const push: CommandDefinition<
|
||||
dockerfilePath,
|
||||
registrySecrets,
|
||||
nocache: options.nocache || false,
|
||||
live: options.live || false,
|
||||
nolive: options.nolive || false,
|
||||
detached: options.detached || false,
|
||||
services: servicesToDisplay,
|
||||
system: options.system || false,
|
||||
|
@ -46,7 +46,7 @@ export interface DeviceDeployOptions {
|
||||
dockerfilePath?: string;
|
||||
registrySecrets: RegistrySecrets;
|
||||
nocache: boolean;
|
||||
live: boolean;
|
||||
nolive: boolean;
|
||||
detached: boolean;
|
||||
services?: string[];
|
||||
system: boolean;
|
||||
@ -149,10 +149,11 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
||||
if (!semver.satisfies(version, '>=7.21.4')) {
|
||||
exitWithExpectedError(versionError);
|
||||
}
|
||||
if (opts.live && !semver.satisfies(version, '>=9.7.0')) {
|
||||
exitWithExpectedError(
|
||||
new Error('Using livepush requires a supervisor >= v9.7.0'),
|
||||
if (!opts.nolive && !semver.satisfies(version, '>=9.7.0')) {
|
||||
globalLogger.logWarn(
|
||||
`Using livepush requires a balena supervisor version >= 9.7.0. A live session will not be started.`,
|
||||
);
|
||||
opts.nolive = true;
|
||||
}
|
||||
} catch {
|
||||
exitWithExpectedError(versionError);
|
||||
@ -180,7 +181,7 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
||||
const deviceInfo = await api.getDeviceInformation();
|
||||
|
||||
let buildLogs: Dictionary<string> | undefined;
|
||||
if (opts.live) {
|
||||
if (!opts.nolive) {
|
||||
buildLogs = {};
|
||||
}
|
||||
const buildTasks = await performBuilds(
|
||||
@ -216,7 +217,7 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
||||
// Now that we've set the target state, the device will do it's thing
|
||||
// so we can either just display the logs, or start a livepush session
|
||||
// (whilst also display logs)
|
||||
if (opts.live) {
|
||||
if (!opts.nolive) {
|
||||
const livepush = new LivepushManager({
|
||||
api,
|
||||
buildContext: opts.source,
|
||||
|
Loading…
x
Reference in New Issue
Block a user