-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save BuildKit state on client for cache support
Signed-off-by: CrazyMax <[email protected]>
- Loading branch information
Showing
9 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as uuid from 'uuid'; | ||
import * as context from './context'; | ||
import * as exec from '@actions/exec'; | ||
|
||
export async function volumeCreate(dir: string, name: string): Promise<void> { | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir, {recursive: true}); | ||
} | ||
return await exec | ||
.getExecOutput(`docker`, ['volume', 'create', '--name', `${name}`, '--driver', 'local', '--opt', `o=bind,acl`, '--opt', 'type=none', '--opt', `device=${dir}`], { | ||
ignoreReturnCode: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr.trim()); | ||
} | ||
}); | ||
} | ||
|
||
export async function volumeRemove(name: string): Promise<void> { | ||
return await exec | ||
.getExecOutput(`docker`, ['volume', 'rm', '-f', `${name}`], { | ||
ignoreReturnCode: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr.trim()); | ||
} | ||
}); | ||
} | ||
|
||
export async function containerCreate(image: string, volume: string): Promise<string> { | ||
return await exec | ||
.getExecOutput(`docker`, ['create', '--rm', '-v', `${volume}`, `${image}`], { | ||
ignoreReturnCode: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr.trim()); | ||
} | ||
return res.stdout.trim(); | ||
}); | ||
} | ||
|
||
export async function containerCopy(ctnid: string, src: string): Promise<string> { | ||
const outdir = path.join(context.tmpDir(), `ctn-copy-${uuid.v4()}`).split(path.sep).join(path.posix.sep); | ||
return await exec | ||
.getExecOutput(`docker`, ['cp', '-a', `${src}`, `${outdir}`], { | ||
ignoreReturnCode: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr.trim()); | ||
} | ||
return outdir; | ||
}); | ||
} | ||
|
||
export async function containerRemove(ctnid: string): Promise<void> { | ||
return await exec | ||
.getExecOutput(`docker`, ['rm', '-f', '-v', `${ctnid}`], { | ||
ignoreReturnCode: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr.trim()); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters