本文整理汇总了TypeScript中docker-common/fileutils.findDockerFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript findDockerFile函数的具体用法?TypeScript findDockerFile怎么用?TypeScript findDockerFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findDockerFile函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
export function run(connection: ContainerConnection, outputUpdate: (data: string) => any, ignoreArguments?: boolean): any {
let commandArguments = ignoreArguments ? "" : tl.getInput("arguments");
// get tags input
let tags = tl.getDelimitedInput("tags", "\n");
// get qualified image name from the containerRegistry input
let repositoryName = tl.getInput("repository");
let imageNames: string[] = [];
// if container registry is provided, use that
// else, use the currently logged in registries
if (tl.getInput("containerRegistry")) {
let imageName = connection.getQualifiedImageName(repositoryName);
if (imageName) {
imageNames.push(imageName);
}
}
else {
imageNames = connection.getQualifiedImageNamesFromConfig(repositoryName);
}
const dockerfilepath = tl.getInput("dockerFile", true);
const dockerFile = findDockerFile(dockerfilepath);
if (!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
// push all tags
let output = "";
let outputImageName = "";
let digest = "";
let imageSize = "";
let promise = pushMultipleImages(connection, imageNames, tags, commandArguments, (image, commandOutput) => {
output += commandOutput;
outputImageName = image;
let extractedResult = extractDigestAndSizeFromOutput(commandOutput, matchPatternForDigestAndSize);
digest = extractedResult[0];
imageSize = extractedResult[1];
tl.debug("outputImageName: " + outputImageName + "\n" + "commandOutput: " + commandOutput + "\n" + "digest:" + digest + "imageSize:" + imageSize);
publishToImageMetadataStore(connection, outputImageName, tags, digest, dockerFile, imageSize).then((result) => {
tl.debug("ImageDetailsApiResponse: " + result);
}, (error) => {
tl.warning("publishToImageMetadataStore failed with error: " + error);
});
});
if (promise) {
promise = promise.then(() => {
let taskOutputPath = utils.writeTaskOutput("push", output);
outputUpdate(taskOutputPath);
});
}
else {
tl.debug(tl.loc('NotPushingAsNoLoginFound'));
promise = Q.resolve(null);
}
return promise;
}
示例2: run
export function run(connection: ContainerConnection): any {
var command = connection.createCommand();
command.arg("build");
var dockerfilepath = tl.getInput("dockerFile", true);
let dockerFile = fileUtils.findDockerFile(dockerfilepath);
if(!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
command.arg(["-f", dockerFile]);
var addDefaultLabels = tl.getBoolInput("addDefaultLabels");
if (addDefaultLabels) {
pipelineUtils.addDefaultLabelArgs(command);
}
var commandArguments = tl.getInput("arguments", false);
command.line(commandArguments);
var imageName = utils.getImageName();
var qualifyImageName = tl.getBoolInput("qualifyImageName");
if (qualifyImageName) {
imageName = connection.getQualifiedImageNameIfRequired(imageName);
}
command.arg(["-t", tl.getBoolInput("enforceDockerNamingConvention") ? imageUtils.generateValidImageName(imageName) : imageName]);
var baseImageName = imageUtils.imageNameWithoutTag(imageName);
var includeSourceTags = tl.getBoolInput("includeSourceTags");
if (includeSourceTags) {
sourceUtils.getSourceTags().forEach(tag => {
command.arg(["-t", baseImageName + ":" + tag]);
});
}
var includeLatestTag = tl.getBoolInput("includeLatestTag");
if (baseImageName !== imageName && includeLatestTag) {
command.arg(["-t", baseImageName]);
}
var memoryLimit = tl.getInput("memoryLimit");
if (memoryLimit) {
command.arg(["-m", memoryLimit]);
}
var context: string;
var useDefaultContext = tl.getBoolInput("useDefaultContext");
if (useDefaultContext) {
context = path.dirname(dockerFile);
} else {
context = tl.getPathInput("buildContext");
}
command.arg(context);
return connection.execCommand(command);
}
示例3: run
export function run(connection: ContainerConnection, outputUpdate: (data: string) => any, ignoreArguments?: boolean): any {
// find dockerfile path
let dockerfilepath = tl.getInput("Dockerfile", true);
let dockerFile = fileUtils.findDockerFile(dockerfilepath);
if(!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
// get command arguments
let commandArguments = ignoreArguments ? "" : tl.getInput("arguments", false);
// get qualified image names by combining container registry(s) and repository
let repositoryName = tl.getInput("repository");
let imageNames: string[] = [];
// if container registry is provided, use that
// else, use the currently logged in registries
if (tl.getInput("containerRegistry")) {
let imageName = connection.getQualifiedImageName(repositoryName);
if (imageName) {
imageNames.push(imageName);
}
}
else {
imageNames = connection.getQualifiedImageNamesFromConfig(repositoryName);
}
// get label arguments
let labelArguments = pipelineUtils.getDefaultLabels();
// get tags input
let tags = tl.getDelimitedInput("tags", "\n");
let tagArguments: string[] = [];
// find all the tag arguments to be added to the command
if (imageNames && imageNames.length > 0) {
imageNames.forEach(imageName => {
if (tags && tags.length > 0) {
tags.forEach(tag => {
tagArguments.push(imageName + ":" + tag);
});
}
else {
// pass just the imageName and not the tag. This will tag the image with latest tag as per the default behavior of the build command.
tagArguments.push(imageName);
}
});
}
else {
tl.debug(tl.loc('NotAddingAnyTagsToBuild'));
}
// get build context
let buildContext = tl.getPathInput("buildContext");
if (useDefaultBuildContext(buildContext)) {
buildContext = path.dirname(dockerFile);
}
let output = "";
return dockerCommandUtils.build(connection, dockerFile, buildContext, commandArguments, labelArguments, tagArguments, (data) => output += data).then(() => {
let taskOutputPath = utils.writeTaskOutput("build", output);
outputUpdate(taskOutputPath);
});
}