Skip to content

Commit 3750cbe

Browse files
committed
make allowImageBuild configurable for free envs
1 parent 11806ae commit 3750cbe

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

docs/env.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ The `DOCKER_COMPUTE_ENVIRONMENTS` environment variable should be a JSON array of
218218
- **maxJobDuration**: Maximum duration in seconds for a free job.
219219
- **minJobDuration**: Minimum duration in seconds for a free job.
220220
- **maxJobs**: Maximum number of simultaneous free jobs.
221+
- **allowImageBuild**: If building images is allowed on free envs. Default: false
221222
- **access**: Access control configuration for free compute jobs. Works the same as the main `access` field.
222223
- **addresses**: Array of Ethereum addresses allowed to run free compute jobs.
223224
- **accessLists**: Array of AccessList contract addresses for free compute access control.

src/@types/C2D/C2D.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export interface ComputeEnvironmentFreeOptions {
106106
maxJobs?: number // maximum number of simultaneous free jobs
107107
resources?: ComputeResource[]
108108
access: ComputeAccessList
109+
allowImageBuild?: boolean
109110
}
110111
export interface ComputeEnvironmentBaseConfig {
111112
description?: string // v1

src/components/c2d/compute_engine_docker.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,9 +1108,13 @@ export class C2DEngineDocker extends C2DEngine {
11081108
throw new Error(`additionalDockerFiles cannot be used with queued jobs`)
11091109
}
11101110
}
1111-
// if (algorithm.meta.container && algorithm.meta.container.dockerfile && isFree) {
1112-
// throw new Error(`Building image is not allowed for free jobs`)
1113-
// }
1111+
if (
1112+
algorithm.meta.container &&
1113+
algorithm.meta.container.dockerfile &&
1114+
!env.free.allowImageBuild
1115+
) {
1116+
throw new Error(`Building image is not allowed for free jobs`)
1117+
}
11141118

11151119
const job: DBComputeJob = {
11161120
clusterHash: this.getC2DConfig().hash,

src/utils/config/schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ export const ComputeEnvironmentFreeOptionsSchema = z.object({
153153
.nullable()
154154
.optional()
155155
})
156-
.optional()
156+
.optional(),
157+
allowImageBuild: z.boolean().optional().default(false)
157158
})
158159

159160
export const C2DDockerConfigSchema = z.array(

0 commit comments

Comments
 (0)