How to use the @pulumi/docker.buildAndPushImage function in @pulumi/docker

To help you get started, we’ve selected a few @pulumi/docker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / pulumi-awsx / nodejs / aws-infra / experimental / containerDefinition.ts View on Github external
imageName: string,
        repositoryUrl: string,
        registryId: string,
        logResource: pulumi.Resource) {

    // See if we've already built this.
    let uniqueImageName = buildImageCache.get(imageName);
    if (uniqueImageName) {
        uniqueImageName.apply(d =>
            pulumi.log.debug(`    already built: ${imageName} (${d})`, logResource));
    }
    else {
        // If we haven't, build and push the local build context to the ECR repository.  Then return
        // the unique image name we pushed to.  The name will change if the image changes ensuring
        // the TaskDefinition get's replaced IFF the built image changes.
        uniqueImageName = docker.buildAndPushImage(imageName, build, repositoryUrl, logResource, async () => {
            // Construct Docker registry auth data by getting the short-lived authorizationToken from ECR, and
            // extracting the username/password pair after base64-decoding the token.
            //
            // See: http://docs.aws.amazon.com/cli/latest/reference/ecr/get-authorization-token.html
            if (!registryId) {
                throw new Error("Expected registry ID to be defined during push");
            }
            const credentials = await aws.ecr.getCredentials({ registryId: registryId });
            const decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString();
            const [username, password] = decodedCredentials.split(":");
            if (!password || !username) {
                throw new Error("Invalid credentials");
            }
            return {
                registry: credentials.proxyEndpoint,
                username: username,
github pulumi / pulumi-cloud / aws / service.ts View on Github external
logResource: pulumi.Resource): pulumi.Output {

    let imageDigest: pulumi.Output;
    // See if we've already built this.
    if (imageName && buildImageCache.has(imageName)) {
        // We got a cache hit, simply reuse the existing digest.
        // Safe to ! the result since we checked buildImageCache.has above.
        imageDigest = buildImageCache.get(imageName)!;
        imageDigest.apply(d =>
            pulumi.log.debug(`    already built: ${imageName} (${d})`, logResource));
    } else {
        // If we haven't, build and push the local build context to the ECR repository, wait for
        // that to complete, then return the image name pointing to the ECT repository along
        // with an environment variable for the image digest to ensure the TaskDefinition get's
        // replaced IFF the built image changes.
        imageDigest = docker.buildAndPushImage(imageName, build, repositoryUrl, logResource, async () => {
            // Construct Docker registry auth data by getting the short-lived authorizationToken from ECR, and
            // extracting the username/password pair after base64-decoding the token.
            //
            // See: http://docs.aws.amazon.com/cli/latest/reference/ecr/get-authorization-token.html
            if (!registryId) {
                throw new RunError("Expected registry ID to be defined during push");
            }
            const credentials = await aws.ecr.getCredentials({ registryId: registryId });
            const decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString();
            const [username, password] = decodedCredentials.split(":");
            if (!password || !username) {
                throw new RunError("Invalid credentials");
            }
            return {
                registry: credentials.proxyEndpoint,
                username: username,
github pulumi / pulumi-cloud / azure / service.ts View on Github external
repositoryUrl: string,
    dockerRegistry: docker.Registry,
    logResource: pulumi.Resource): pulumi.Output {

    let uniqueImageName = buildImageCache.get(imageName);
    // See if we've already built this.
    if (uniqueImageName) {
        uniqueImageName.apply(d =>
            pulumi.log.debug(`    already built: ${imageName} (${d})`, logResource));
    }
    else {
        // If we haven't, build and push the local build context to the azure docker repository.
        // Then return the unique name given to this image in that repository. The name will change
        // if the image changes ensuring the TaskDefinition get's replaced IFF the built image
        // changes.
        uniqueImageName = docker.buildAndPushImage(
            imageName, build, repositoryUrl, logResource,
            async () => dockerRegistry);

        uniqueImageName.apply(d =>
            pulumi.log.debug(`    build complete: ${imageName} (${d})`, logResource));
    }

    return createImageOptions(uniqueImageName, preEnv);
}

@pulumi/docker

A Pulumi package for interacting with Docker in Pulumi programs

Apache-2.0
Latest version published 22 days ago

Package Health Score

92 / 100
Full package analysis