sparse-intern-71089
10/06/2019, 12:05 PMgorgeous-egg-16927
10/07/2019, 3:28 PMconst image = awsx.ecr.buildAndPushImage(apiRepoName, config.dockerContextPath, ...).imageValue;
to get the image name for k8s. If you need the fully-qualified name, you could do something like
const repoImage = awsx.ecr.buildAndPushImage(apiRepoName, config.dockerContextPath, ...);
const fqImage = pulumi.concat(repoImage.repository, ":", repoImage.imageValue);
acoustic-noon-6208
10/07/2019, 4:54 PMexport declare abstract class Image implements ecs.ContainerImageProvider
and
export declare class RepositoryImage implements ecs.ContainerImageProvider
acoustic-noon-6208
10/07/2019, 4:55 PMawsx.ecr.buildAndPushImage
seems returns instance of some class which inherits abstract Image
, while you suggest to use properties (.imageValue
or .repository
) from RepositoryImage
acoustic-noon-6208
10/07/2019, 4:56 PMContainerImageProvider
does not have such properties defined...)gorgeous-egg-16927
10/08/2019, 7:23 PMconst repoImage = awsx.ecr.buildAndPushImage("test", ".");
const appLabels = { app: "test" };
const deployment = new k8s.apps.v1.Deployment("test", {
spec: {
selector: { matchLabels: appLabels },
replicas: 1,
template: {
metadata: { labels: appLabels },
spec: {
containers: [{ name: "test", image: repoImage.imageValue}],
},
},
}
},
);
worked for me. Apparently you just need the imageValue
propertyacoustic-noon-6208
10/09/2019, 11:04 AMconst apiImage = awsx.ecs.Image.fromDockerBuild(repositoryApi, {
context: config.dockerContextPath,
dockerfile: config.dockerAPIFile
});
i.e. fromDockerBuild
, not buildAndPushImage
acoustic-noon-6208
10/09/2019, 11:06 AMawsx.ecr.RepositoryImage
(which has property imageValue), but return type is awsx.ecs.Image
acoustic-noon-6208
10/11/2019, 11:20 PMbuildAndPushImage
and for usage in Fargate with `fromDockerBuild`:
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as config from "./config";
import { Environment } from "./environments";
export const createDockerImages = async (environment: Environment) => {
const apiRepoName = `gauzy/api-${environment.toLowerCase()}`;
const repositoryApi = new aws.ecr.Repository(apiRepoName, {
name: apiRepoName
});
const webappRepoName = `gauzy/webapp-${environment.toLowerCase()}`;
const repositoryWebapp = new aws.ecr.Repository(webappRepoName, {
name: webappRepoName
});
let apiImage;
// Build and publish a Docker image to a private ECR registry for API.
if (environment !== Environment.Prod)
{
apiImage = awsx.ecs.Image.fromDockerBuild(repositoryApi, {
context: config.dockerContextPath,
dockerfile: config.dockerAPIFile
});
}
else
{
apiImage = awsx.ecr.buildAndPushImage(
apiRepoName,
{
context: config.dockerContextPath,
dockerfile: config.dockerAPIFile
},
{ repository: repositoryApi }
);
}
let webappImage;
// Build and publish a Docker image to a private ECR registry for Web App.
if (environment !== Environment.Prod)
{
webappImage = awsx.ecs.Image.fromDockerBuild(repositoryWebapp, {
context: config.dockerContextPath,
dockerfile: config.dockerWebappFile
});
}
else
{
webappImage = awsx.ecr.buildAndPushImage(
webappRepoName,
{
context: config.dockerContextPath,
dockerfile: config.dockerWebappFile
},
{ repository: repositoryWebapp }
);
}
return { apiImage, webappImage };
};