Hi everyone,
I just created a function to build my mini monorepo using Dagger. This function is supposed to replace the entire build command in the Dockerfile. I'm calling it with the command: dagger call build-backend --service-name=user --source .., but I'm receiving an error like the one in the title. You can find my Dagger Cloud link here: https://dagger.cloud/duclee/traces/bec99e298723b1ff84bf579acebcb1d4.
Any insights for debugging would be appreciated!
the current dagger function files:
`@object()
export class Pipelines {
@func()
installPackage(source: Directory): Container {
return dag
.container()
.from("oven/bun:1.2.11-alpine")
.withWorkdir("/app")
.withMountedCache("./node_modules", dag.cacheVolume("monorepo_node_modules"))
.withDirectory(".", source, {include: ["package.json","./**/*/package.json"]})
.withExec(["bun","install","--frozen-lockfile"])
}
@func()
buildBackend(serviceName: string, source: Directory): Container {
const serviceList = Object.keys(ServiceName);
if (!serviceList.includes(serviceName)) {
throw new Error(Service name '${serviceName}' is not recognized. Available services: ${Object.keys(ServiceName).join(", ")});
}
const packages = this.installPackage(source); // cache the result!
return dag
.container()
.from("oven/bun:1.2.11-alpine")
.withWorkdir("/app")
.terminal()
.withDirectory("./node_modules", packages.directory("/app/node_modules"))
.withFile("./package.json", packages.file("./package.json"))
.withDirectory(./src/${serviceName+"-service"}, source.directory(./src/${serviceName+"-service"}))
.withEnvVariable("DATABASE_URL", "file:./dev.db")
.withExec(["bun","prisma:generate"])
.withExec(["bun","run","build"])
.terminal()
}
}
`