Skip to content

Image

Source: src/AWS/ECR/Image.ts

A Docker image built from a local context and pushed to a private Amazon ECR repository.

The image is identified by a content hash over the build context, Dockerfile, platform, and build args. Reconcile rebuilds and pushes only when that hash changes — a content change produces a new tag and digest on the same resource, so replacement is never needed.

Push to an ECR Repository

const repository = yield* AWS.ECR.Repository("AppRepository", {});
const image = yield* AWS.ECR.Image("AppImage", {
repositoryUri: repository.repositoryUri,
context: "./app",
});

Auto-created Repository

const image = yield* AWS.ECR.Image("AppImage", {
context: "./app",
});
const image = yield* AWS.ECR.Image("WorkerImage", {
repositoryUri: repository.repositoryUri,
context: "./worker",
dockerfile: "Dockerfile.worker",
platform: "linux/arm64",
buildArgs: { NODE_ENV: "production" },
});
const task = yield* AWS.ECS.Task("ApiTask", {
main: import.meta.url,
sidecars: [{ name: "proxy", image: image.imageUri, essential: false }],
});