You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have my source code in ~/projects/repo, and I have a Dockerfile inside ~/dockerfiles.
I'm trying to write a script where I can pass in the source code path, like " ~/projects/repo", and then it will run the Dockerfile against that. So I thought I could do someting like:
importDockerfrom'dockerode';importfsfrom'fs';importpathfrom'path';importurlfrom'url';import{nanoid}from'nanoid';import{LogStream}from'./utils/log-stream.mjs'constdocker=newDocker();const__dirname=path.dirname(url.fileURLToPath(import.meta.url))constdockerFilePath=path.join(__dirname,'../dockerfiles/Dockerfile')exportasyncfunctionbuildImage(sourcePath,imageName,deploymentId){buildId=nanoid()constabsoluteSourcePath=path.resolve(sourcePath);if(!fs.existsSync(absoluteSourcePath)){thrownewError(`Source path '${absoluteSourcePath}' does not exist`);}awaitdocker.buildImage({context: absoluteSourcePath,src: [dockerFilePath]},{t: imageName});console.log(`[${buildId}] Docker image '${imageName}' built successfully`);}
So then I can run buildImage("~/projects/my-repo", "my-repo", "repo-id").
Although I get the error
Error: ENOENT: no such file or directory, lstat '~/projects/my-repo/Users/bitttttten/dockerfiles/Dockerfile'
}```In theory it looks like it should work, however it seems to be putting the Dockerfile onto the context, rather than looking for it relatively. Am I doing something wrong here? I've tried many different combinations and so far I'm stuck 😅
The text was updated successfully, but these errors were encountered:
I've tried every combination as well. This seems to be a limitation of dockerode. A possible workaround is moving the Dockerfile to the top directory and having it named "Dockerfile" but this isn't ideal for every project.
I have my source code in ~/projects/repo, and I have a Dockerfile inside ~/dockerfiles.
I'm trying to write a script where I can pass in the source code path, like " ~/projects/repo", and then it will run the Dockerfile against that. So I thought I could do someting like:
So then I can run
buildImage("~/projects/my-repo", "my-repo", "repo-id")
.Although I get the error
The text was updated successfully, but these errors were encountered: