sparse-intern-71089
11/28/2021, 5:58 PMsteep-sunset-89396
11/28/2021, 11:32 PMsteep-sunset-89396
11/28/2021, 11:33 PMdocker.buildAndPushImage()
to biuld the image before pushing to the registry, the first parameter is your image namesteep-sunset-89396
11/28/2021, 11:36 PMprivate computeImageFromAsset(appPath: string, repositoryUrl: string, registryId: string, parent: pulumi.Resource): pulumi.Output<string> {
let imageName = this.args.imageName;
let dockerBuildArgs: any = {};
let _dockerBuild: docker.DockerBuild = {
args: dockerBuildArgs,
context: appPath,
dockerfile: `${appPath}/Dockerfile`,
cacheFrom: {},
};
const uniqueImageName = docker.buildAndPushImage(imageName, _dockerBuild, repositoryUrl, parent, async () => {
let credentials = await aws.ecr.getCredentials({
registryId: registryId
}, {
parent, async: true
});
let decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString();
let [username, password] = decodedCredentials.split(":");
if (!password || !username) {
throw new Error("Invalid credentials");
}
return {
registry: credentials.proxyEndpoint,
username: username,
password: password,
};
});
uniqueImageName.apply(d => pulumi.log.debug(` build complete: ${imageName} (${d})`, parent));
return uniqueImageName;
}
wide-whale-78548
11/29/2021, 8:44 AMaws.ecr.getCredentials
method exits and that was very helpful.steep-sunset-89396
11/29/2021, 8:51 AMwide-whale-78548
11/29/2021, 8:58 AM