11import * as ecr from '@aws-cdk/aws-ecr' ;
2+ import { Platform } from '@aws-cdk/aws-ecr-assets' ;
23import { Construct } from 'constructs' ;
4+ import { Architecture } from './architecture' ;
35import { AssetImageCode , AssetImageCodeProps , EcrImageCode , EcrImageCodeProps , Code } from './code' ;
46import { Function , FunctionOptions } from './function' ;
57import { Handler } from './handler' ;
@@ -41,8 +43,12 @@ export abstract class DockerImageCode {
4143 */
4244 public static fromImageAsset ( directory : string , props : AssetImageCodeProps = { } ) : DockerImageCode {
4345 return {
44- _bind ( ) {
45- return new AssetImageCode ( directory , props ) ;
46+ _bind ( architecture ?: Architecture ) {
47+ return new AssetImageCode ( directory , {
48+ // determine the platform from `architecture`.
49+ ...architecture ?. dockerPlatform ? { platform : Platform . custom ( architecture . dockerPlatform ) } : { } ,
50+ ...props ,
51+ } ) ;
4652 } ,
4753 } ;
4854 }
@@ -51,7 +57,7 @@ export abstract class DockerImageCode {
5157 * Produce a `Code` instance from this `DockerImageCode`.
5258 * @internal
5359 */
54- public abstract _bind ( ) : Code ;
60+ public abstract _bind ( architecture ?: Architecture ) : Code ;
5561}
5662
5763/**
@@ -63,7 +69,7 @@ export class DockerImageFunction extends Function {
6369 ...props ,
6470 handler : Handler . FROM_IMAGE ,
6571 runtime : Runtime . FROM_IMAGE ,
66- code : props . code . _bind ( ) ,
72+ code : props . code . _bind ( props . architecture ) ,
6773 } ) ;
6874 }
6975}
0 commit comments