Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
import * as aws from '@pulumi/aws';
import * as awsx from '@pulumi/awsx';
import * as pulumi from '@pulumi/pulumi';
export class EcrImage extends pulumi.ComponentResource {
public ecr: awsx.ecr.Repository;
public image: awsx.ecr.Image;
public tags: { [key: string]: string };
constructor(
name: string,
{
repositoryId,
repositoryName,
imageId,
imagePath,
platform,
dockerfile,
buildArgs,
tags,
}: {
repositoryId: string;
repositoryName: string;
imageId: string;
imagePath: string;
platform: { family: string; architecture: string };
dockerfile?: string;
buildArgs?: { [key: string]: string };
tags: { [key: string]: string };
},
opts?: pulumi.ComponentResourceOptions
) {
super('my:components:EcrImage', name, {}, opts);
this.tags = tags;
this.ecr = new awsx.ecr.Repository(
repositoryId,
{
name: repositoryName,
imageTagMutability: 'MUTABLE',
forceDelete: true,
tags: this.tags,
lifecyclePolicy: {
// We do not want the default lifecycle policy for the repositories
skip: true,
},
},
{ parent: this }
);
new aws.ecr.LifecyclePolicy(
`${repositoryId}-lifecycle-policy`,
{
repository: this.ecr.repository.id,
policy: {
rules: [
{
rulePriority: 1,
// Count, not age: once `latest` moves, the image the previous task
// definition pins is untagged, and ECS rollbacks and task
// replacements still need to pull it.
description: 'keep the 20 most recent untagged images',
selection: {
tagStatus: 'untagged',
countType: 'imageCountMoreThan',
countNumber: 20,
},
action: {
type: 'expire',
},
},
],
},
},
{ parent: this }
);
const usePrebuiltServiceBinaries =
process.env.USE_PREBUILT_SERVICE_BINARIES === 'true';
const prebuiltDockerfiles: { [key: string]: string } = {
'docker/Dockerfile': 'docker/Dockerfile.prebuilt',
'docker/Dockerfile.convert_service':
'docker/Dockerfile.convert_service.prebuilt',
'docker/Dockerfile.search_processing_service':
'docker/Dockerfile.search_processing_service.prebuilt',
};
const effectiveDockerfile = (() => {
if (!usePrebuiltServiceBinaries) {
return dockerfile;
}
const dockerfileKey = dockerfile ?? 'docker/Dockerfile';
const prebuiltDockerfile = prebuiltDockerfiles[dockerfileKey];
if (!prebuiltDockerfile) {
throw new Error(
`No prebuilt Dockerfile mapping configured for ${dockerfileKey}`
);
}
return prebuiltDockerfile;
})();
this.image = new awsx.ecr.Image(
imageId,
{
imageTag: 'latest',
context: imagePath,
platform: `${platform.family}/${platform.architecture}`,
dockerfile: effectiveDockerfile
? `${imagePath}/${effectiveDockerfile}`
: undefined,
repositoryUrl: this.ecr.url,
args: buildArgs,
},
{ parent: this }
);
}
}