-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathdocker.ts
More file actions
87 lines (83 loc) · 1.86 KB
/
docker.ts
File metadata and controls
87 lines (83 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import * as task from 'azure-pipelines-task-lib/task';
import * as docker from '../../../common/src/docker';
import {exec} from './exec';
export async function isDockerBuildXInstalled(): Promise<boolean> {
return await docker.isDockerBuildXInstalled(exec);
}
export async function buildImage(
imageName: string,
imageTag: string | undefined,
checkoutPath: string,
subFolder: string,
skipContainerUserIdUpdate: boolean,
cacheFrom: string[],
cacheTo: string[],
): Promise<string> {
console.log('🏗 Building dev container...');
try {
return await docker.buildImage(
exec,
imageName,
imageTag,
checkoutPath,
subFolder,
skipContainerUserIdUpdate,
cacheFrom,
cacheTo,
);
} catch (error) {
task.setResult(task.TaskResult.Failed, error);
return '';
}
}
export async function runContainer(
imageName: string,
imageTag: string | undefined,
checkoutPath: string,
subFolder: string,
command: string,
envs?: string[],
): Promise<boolean> {
console.log('🏃♀️ Running dev container...');
try {
await docker.runContainer(
exec,
imageName,
imageTag,
checkoutPath,
subFolder,
command,
envs,
);
return true;
} catch (error) {
task.setResult(task.TaskResult.Failed, error);
return false;
}
}
export async function pushImage(
imageName: string,
imageTag: string | undefined,
): Promise<boolean> {
console.log('📌 Pushing image...');
try {
await docker.pushImage(exec, imageName, imageTag);
return true;
} catch (error) {
task.setResult(task.TaskResult.Failed, error);
return false;
}
}
export async function createMultiPlatformImage(
imageName: string,
tag: string,
platformTags: string[],
): Promise<boolean> {
try {
await docker.createMultiPlatformImage(exec, imageName, tag, platformTags);
return true;
} catch (error) {
task.setResult(task.TaskResult.Failed, `${error}`);
return false;
}
}