How to use @pulumi/docker - 9 common examples

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);
}
github pulumi / examples / gcp-ts-k8s-ruby-on-rails-postgresql / infra / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

import * as docker from "@pulumi/docker";
import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";
import * as cluster from "./cluster";
import * as config from "./config";
import * as db from "./db";

// Get the GCR repository for our app container, and build and publish the app image.
const appImage = new docker.Image("rails-app", {
    imageName: `${config.dockerUsername}/${pulumi.getProject()}_${pulumi.getStack()}`,
    build: "../app",
    registry: {
        server: "docker.io",
        username: config.dockerUsername,
        password: config.dockerPassword,
    },
});

// Deploy the app container as a Kubernetes load balanced service.
const appPort = 3000;
const appLabels = { app: "rails-app" };
const appDeployment = new k8s.apps.v1.Deployment("rails-deployment", {
    spec: {
        selector: { matchLabels: appLabels },
        replicas: 1,
github pulumi / kubernetes-guides / gcp / 06-apps / build-deploy-container / index.ts View on Github external
// limitations under the License.

import * as docker from "@pulumi/docker";
import * as gcp from "@pulumi/gcp";
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
import * as pulumi from "@pulumi/pulumi";
import { config } from "./config";

// Get the GCP project registry repository.
const registry = gcp.container.getRegistryRepository();

// Build a Docker image from a local Dockerfile context in the
// './node-app' directory, and push it to the registry.
const customImage = "node-app";
const appImage = new docker.Image(customImage, {
    imageName: pulumi.interpolate`${registry.repositoryUrl}/${customImage}:v1.0.0`,
    build: {
        context: `./${customImage}`,
    },
});

// Create a k8s provider.
const provider = new k8s.Provider("provider", {
    kubeconfig: config.kubeconfig,
    namespace: config.appsNamespaceName,
});

// Create a Deployment of the built container.
const appLabels = { app: customImage };
const appDeployment = new k8s.apps.v1.Deployment("app", {
    spec: {
github pulumi / kubernetes-guides / azure / 06-apps / build-deploy-container / index.ts View on Github external
import { config } from "./config";

// Create an Azure Resource Group
const resourceGroup = new azure.core.ResourceGroup("samples");

// Create a registry in ACR.
const registry = new azure.containerservice.Registry("myregistry", {
    resourceGroupName: resourceGroup.name,
    sku: "Basic",
    adminEnabled: true,
});

// Build a Docker image from a local Dockerfile context in the
// './node-app' directory, and push it to the registry.
const customImage = "node-app";
const appImage = new docker.Image(customImage, {
    imageName: pulumi.interpolate`${registry.loginServer}/${customImage}:v1.0.0`,
    build: {
        context: `./${customImage}`,
    },
    registry: {
        server: registry.loginServer,
        username: registry.adminUsername,
        password: registry.adminPassword,
    },
});

// Create a k8s provider.
const provider = new k8s.Provider("provider", {
    kubeconfig: config.kubeconfig,
    namespace: config.appsNamespaceName,
});
github pulumi / examples / azure-ts-aks-keda / keda.ts View on Github external
constructor(name: string,
                args: KedaStorageQueueHandlerArgs,
                opts: pulumi.ComponentResourceOptions = {}) {
        super("examples:keda:KedaStorageQueueHandler", name, args, opts);

        const registry = args.service.registry;

        // Deploy the docker image of the Function App
        const dockerImage = new docker.Image("image", {
            imageName: pulumi.interpolate`${registry.loginServer}/${args.queue.name}:v1.0.0`,
            build: {
                context: args.path,
            },
            registry: {
                server: registry.loginServer,
                username: registry.adminUsername,
                password: registry.adminPassword,
            },
        }, { parent: this });

        // Put the storage account connection string into a secret
        const secretQueue = new k8s.core.v1.Secret("queue-secret", {
            data: {
                queueConnectionString:
                    args.storageAccount.primaryConnectionString.apply(c => Buffer.from(c).toString("base64")),
github pulumi / examples / azure-ts-appservice-docker / index.ts View on Github external
export const helloEndpoint = pulumi.interpolate`https://${helloApp.defaultSiteHostname}/hello`;


/**
 * Scenario 2: deploying a custom image from Azure Container Registry.
 */
const customImage = "node-app";

const registry = new azure.containerservice.Registry("myregistry", {
    resourceGroupName: resourceGroup.name,
    sku: "Basic",
    adminEnabled: true,
});

const myImage = new docker.Image(customImage, {
    imageName: pulumi.interpolate`${registry.loginServer}/${customImage}:v1.0.0`,
    build: {
        context: `./${customImage}`,
    },
    registry: {
        server: registry.loginServer,
        username: registry.adminUsername,
        password: registry.adminPassword,
    },
});

const getStartedApp = new azure.appservice.AppService("get-started", {
    resourceGroupName: resourceGroup.name,
    appServicePlanId: plan.id,
    appSettings: {
      WEBSITES_ENABLE_APP_SERVICE_STORAGE: "false",
github pulumi / examples / azure-ts-appservice-springboot / infrastructure / index.ts View on Github external
resourceGroupName: resourceGroup.name,
    reserved: true,
    sku: {
        tier: "Basic",
        size: "B1",
    },
});

const registry = new azure.containerservice.Registry("myacr", {
    resourceGroupName: resourceGroup.name,
    sku: "Basic",
    adminEnabled: true,
});

const customImage = "spring-boot-greeting-app";
const myImage = new docker.Image(customImage, {
    imageName: pulumi.interpolate`${registry.loginServer}/${customImage}:v1.0.0`,
    build: {
        context: `../`,
    },
    registry: {
        server: registry.loginServer,
        username: registry.adminUsername,
        password: registry.adminPassword,
    },
});

const appService = new azure.appservice.AppService(customImage, {
    resourceGroupName: resourceGroup.name,
    appServicePlanId: appServicePlan.id,
    appSettings: {
      WEBSITES_ENABLE_APP_SERVICE_STORAGE: "false",

@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