Skip to content

(assets): allow user to pass platform option to Docker builds #12472

@nikovirtala

Description

@nikovirtala

Use Case

To be able to build images for amd64 architecture (e.g. AWS Fargate) on a system that is using other architecture like arm64 (e.g. Apple M1).

Proposed Solution

Replace docker build with docker buildx build.

https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images

With buildx you can build cross-platform images by declaring --platform argument. e.g. docker buildx build --platform linux/amd64 someimage:sometag . executed on system Apple M1 results in an image which works system with amd64 architecture.

buildx allows you also to build image for multiple platforms at once. e.g. --platform linux/amd64,linux/arm64

Other

Currently image .fromAsset results in an image that works only on the same architecture where it was built. In that sense, this could be considered also a bug – the image built doesn't work on the target system (Fargate).

import { FargateTaskDefinition, ContainerImage } from '@aws-cdk/aws-ecs';

const taskDefinition = new FargateTaskDefinition(this, 'TaskDefinition');

taskDefinition
  .addContainer('Container', {
    image: ContainerImage.fromAsset(path.resolve(__dirname, '../image')),
  });
  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Metadata

Metadata

Assignees

Labels

@aws-cdk/assetsRelated to the @aws-cdk/assets packageeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.feature/enhancementA new API to make things easier or more intuitive. A catch-all for general feature requests.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions