@@ -75,25 +75,36 @@ export const getNormalizedContainerOptions = async (
7575 } ,
7676 } ;
7777
78- let instanceTypeOrDisk : InstanceTypeOrLimits ;
79-
78+ let instanceTypeOrLimits : InstanceTypeOrLimits ;
79+ const MB = 1000 * 1000 ;
8080 if (
8181 container . configuration ?. disk !== undefined ||
8282 container . configuration ?. vcpu !== undefined ||
8383 container . configuration ?. memory_mib !== undefined
8484 ) {
85- const MB = 1000 * 1000 ;
85+ // deprecated path to set a custom instance type
8686 // if an individual limit is not set, default to the dev instance type values
87- instanceTypeOrDisk = {
88- disk_bytes : ( container . configuration . disk ?. size_mb ?? 2000 ) * MB , // defaults to 2GB in bytes
87+ instanceTypeOrLimits = {
88+ disk_bytes : ( container . configuration ? .disk ?. size_mb ?? 2000 ) * MB , // defaults to 2GB in bytes
8989 vcpu : container . configuration ?. vcpu ?? 0.0625 ,
9090 memory_mib : container . configuration ?. memory_mib ?? 256 ,
9191 } ;
92- } else {
93- instanceTypeOrDisk = {
92+ } else if (
93+ typeof container . instance_type === "string" ||
94+ container . instance_type === undefined
95+ ) {
96+ instanceTypeOrLimits = {
9497 instance_type : ( container . instance_type ??
9598 InstanceType . DEV ) as InstanceType ,
9699 } ;
100+ } else {
101+ // set a custom instance type
102+ // any limits that are not set will default to a dev instance type
103+ instanceTypeOrLimits = {
104+ disk_bytes : ( container . instance_type . disk_mb ?? 2000 ) * MB ,
105+ vcpu : container . instance_type . vcpu ?? 0.0625 ,
106+ memory_mib : container . instance_type . memory_mib ?? 256 ,
107+ } ;
97108 }
98109
99110 const maybeDockerfile = isDockerfile ( container . image , config . configPath ) ;
@@ -111,7 +122,7 @@ export const getNormalizedContainerOptions = async (
111122 ) ;
112123 normalizedContainers . push ( {
113124 ...shared ,
114- ...instanceTypeOrDisk ,
125+ ...instanceTypeOrLimits ,
115126 dockerfile : container . image ,
116127 image_build_context : imageBuildContext ,
117128 image_vars : container . image_vars ,
@@ -120,7 +131,7 @@ export const getNormalizedContainerOptions = async (
120131 const accountId = await getAccountId ( config ) ;
121132 normalizedContainers . push ( {
122133 ...shared ,
123- ...instanceTypeOrDisk ,
134+ ...instanceTypeOrLimits ,
124135 image_uri : resolveImageName ( accountId , container . image ) , // if it is not a dockerfile, it must be an image uri or have thrown an error
125136 } ) ;
126137 }
0 commit comments