dockerode
dockerode copied to clipboard
buildImage hangs if called multiple times
I am getting errors with buildImage where it hangs indefinitely for no apparent reason when called the second or third time. I can give maintainers access to my github repo to reproduce or provide any information required if help is available. Here is my buildImage wrapper function:
/**
* build an image
* @param {string} context - provides the path to the Dockerfile.
* @param {string[]} src - Array of files involved in build. All files involved in build must be explicitly mentioned in src array.
* @param {string} nametag - A name and optional tag to apply to the image in the name:tag format. If you omit the tag the default latest value is assumed.
* @returns a Promise of NodeJS stream.
*/
exports.buildImage = async ({ context, src, nametag }) => {
try {
// hangs on this line _forever_
const imageStream = await docker.buildImage({ context, src }, { t: nametag, openStdin: true, });
await new Promise((resolve, reject) => {
docker.modem.followProgress(imageStream, (err, res) => {
if (err) {
console.log('error building image', err);
reject(err);
}
resolve(res);
});
});
return imageStream;
} catch (err) {
throw new Error(`Error building image: `, err);
}
};