-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Docker Buildkit #115
Comments
@AleF83 I had the same issue. The problem here is that when you specify the env param, child_process does not merge it with the current env variables, so you have to do it manually: const options: dockerCompose.IDockerComposeBuildOptions = {
cwd,
env: {
COMPOSE_DOCKER_CLI_BUILD: '1',
DOCKER_BUILDKIT: '1',
...process.env,
},
log: true,
}; Doing so should make your script work. |
Makes sense! I'll send the PR. |
Isn't it not only Docker Buildkit specific? The merging of environment variables I mean? We could just have a |
What about always merging Then we would not need new options |
There are multiple reasons why you would want to avoid that:
In general cases like this should be rather documented instead of trying to implicitly do something for an user. I'd go for explicit env variable merging option. |
Valid reasons 😅 Then, I could add the If I were you, I would just add a note in the readme explaining how things work if you specify the env option (it is not merged to process.env by default) when using this library and maybe also add recommendations on how to deal with that. I would't add any new option unless Thoughts? |
I'm pretty sure that decision was consciously made - and you can see that the thread is already closed. I don't think it's changing anytime soon. If not for anything then for reasons above. Workaround is simple enough and explicit. Just pass your And when adding this option to readme I'd add a big note about possible security implications. |
I'm not sure if I understood you correctly, but just want to clarify my previous comment: I think that the best way to deal with this issue, is not doing anything. I would not change the code to add a new option (mergeEnv) and I would not merge process.env implicitly because of the reasons you mentioned before. Instead, I suggest just adding a note in the readme clarifying that the env option provided to this library is handled as it is to So, keep the implementation as it is, and just improve the docs a little bit. |
Thanks! But this looks very strange and not intuitive. I think that the The fact that the library uses |
I disagree with this statement. The fact that
Currently no defaults are passed because If you do not want to populate subprocess with your whole All-in-all, what's missing is documentation, not helper code. |
I didn't mean object destructoring but using the In the bottom line: COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f <file> up works. await dockerCompose.upAll({
cwd: __dirname,
env: {
COMPOSE_DOCKER_CLI_BUILD: '1',
DOCKER_BUILDKIT: '1',
},
}); doesn't work on the same machine. And this is weird. |
@AleF83 try getting the output from result. export interface IDockerComposeResult {
exitCode: number | null;
out: string;
err: string;
} This result object should be available whether or not promise is resolved or rejected and should contain output from the binary. We could then see what the issue is. You can also pass |
Addition of Error: spawn docker-compose ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn docker-compose',
path: 'docker-compose',
spawnargs: [ 'build' ]
} I printed |
@AleF83 yeah, looks like it can't find |
With await dockerCompose.buildAll({
cwd: __dirname,
env: {
COMPOSE_DOCKER_CLI_BUILD: '1',
DOCKER_BUILDKIT: '1',
PATH: process.env.PATH,
},
log: true,
}); Maybe the |
I tried to run docker-compose with buildkit by adding environment variables:
but it throws error:
The text was updated successfully, but these errors were encountered: