Help with build args #37
|
Hi! I am running into an error where the docker build can't find the package-lock.json file. Im wondering if I have the build context url wrong or if I am passing in the wrong relative path. Can someone help me understand what the buildContext and relativePathToWorkspace path are referring to so I can ensure to set these appropriately? Thanks! |
Replies: 2 comments 4 replies
|
Wow, rookie mistake. Found that I was up too many directories! |
|
The This is the base directory Docker uses to build your application. In the case of ExamplesMonorepo Exampledeploy-app.ts: // ESM example
import { Stack, StackProps } from 'aws-cdk-lib'
import { Construct } from 'constructs'
import { NextjsGlobalFunctions } from 'cdk-nextjs'
import { fileURLToPath } from 'url'
export class DeployAppStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props)
new NextjsGlobalFunctions(this, 'NextApp', {
buildContext: fileURLToPath(new URL('../app', import.meta.url)),
healthCheckPath: '/api/health',
})
}
}In this case:
Non-Monorepo Exampledeploy-app.ts: // ESM example
import { Stack, StackProps } from 'aws-cdk-lib'
import { Construct } from 'constructs'
import { NextjsGlobalFunctions } from 'cdk-nextjs'
import { fileURLToPath } from 'url'
export class DeployAppStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props)
new NextjsGlobalFunctions(this, 'NextApp', {
buildContext: fileURLToPath(new URL('../app', import.meta.url)),
healthCheckPath: '/api/health',
})
}
}In this case:
These examples are loosely based on what I am doing. That said, obviously with a different directory structure, a different relative path may be necessary. |
The
buildContextshould point to the root directory of your Next.js app (wherepackage.jsonandpackage-lock.jsonare located).This is the base directory Docker uses to build your application. In the case of
NextjsGlobalFunctions, thebuildContextensures Docker can locate the app's source files for packaging and deployment.Examples
Monorepo Example
deploy-app.ts: