-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(core): Allow passing platform
via BundlingOptions
#25759
Comments
related to #12472 Yes we should add this support. In fact I was trying to implement that but unfortunately didn't make it. Making this as a p1 feature request. Any community PRs would be highly welcome and appreciated. |
Allowing user to provide a `platform` property when bundling docker assets ([ref](https://docs.docker.com/build/building/multi-platform/)). Currently, this is not possible when using an existing Docker image via the [BundlingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html). You can specify this when building a [DockerImageAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerImageAsset.html#platform), but not when using an image as a builder: Closes #25759. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Allowing user to provide a `platform` property when bundling docker assets ([ref](https://docs.docker.com/build/building/multi-platform/)). Currently, this is not possible when using an existing Docker image via the [BundlingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html). You can specify this when building a [DockerImageAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerImageAsset.html#platform), but not when using an image as a builder: Closes #25759. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Allowing user to provide a `platform` property when bundling docker assets ([ref](https://docs.docker.com/build/building/multi-platform/)). Currently, this is not possible when using an existing Docker image via the [BundlingOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html). You can specify this when building a [DockerImageAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr_assets.DockerImageAsset.html#platform), but not when using an image as a builder: Closes aws#25759. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the feature
It would be nice to be able to enforce the
platform
that any arbitrary docker bundling command uses via theBundlingOptions
property.Currently, this is not possible when using an existing Docker image via the
BundlingOptions
. You can specify this when building an image, but not when using an image as a builder:aws-cdk/packages/aws-cdk-lib/aws-ecr-assets/lib/image-asset.ts
Lines 247 to 252 in 784cd0e
Use Case
We make use of the S3 Deployment
BucketDeployment
construct to package a Virtual Environment dependency zipfile for EMR Serverless (docs).The process to produce the asset looks like this:
The issue is that our
emr-serverless-base-python-3-9-16
is a Multi-Platform image. The EMR serverless runtime environment islinux/amd64
, and our developer machines uselinux/arm64
(Apple Silicon) processors. When we run the build from our local machines, Docker will automatically select thelinux/arm64
variant. Therefore, as it stands, building the image from our local machines produces incompatiblevenv
s.Proposed Solution
Expose a
platform
option in theBundlingOptions
property. When specified, the underlyingdocker run
should use theplatform
flag as specified in theBundlingOptions.platform
property.Other Information
For now, I can work around this by using the
DockerImage.from_build
function which accepts aplatform
parameter.So the
image
specification changes to look like this:The
emr_serverless_docker
folder contains one file (Dockerfile
):FROM --platform=linux/amd64 REDACTED.dkr.ecr.us-west-2.amazonaws.com/data-services:emr-serverless-base-python-3-9-16
(I'm not 100% sure I need to have the
--platform
specified here again, but I did it just to be safe).This works and ensures that the
linux/amd64
version is always selected no matter the host pAcknowledgements
CDK version used
2.80.0
Environment details (OS name and version, etc.)
MacOS
The text was updated successfully, but these errors were encountered: