I have the following situation: I have one Node.js app which uses MongoDB so that with Docker Compose I can have two containers: one for the Node app and another one for the MongoDB.
Now, the app must suppor the following feature: one can upload a csv file which will be imported into Mongo using mongoimport.
With Node, running mongoimport is easy, because we have the exec function. That is, it would be a matter of doing something like:
const exec = require('child_process').exec;
exec('mongoimport -d database -c collection --type csv file.csv', function (error, stdout, stderr) {
// Other stuff here...
});
The only problem is: mongoimport will not be available, because MongoDB is inside another container than the Node app!
Now how can this be solved? I thought on using ssh through exec to run this on the Mongo container, but I'm unsure about it.
How can I run the mongoimport from the Node app into the Mongo container?
apt-getstatement to the dockerfile right?httpway you mention would be to create a simple web api which waits for a request in a particular endpoint and on such request performs the import using the data on the volume right? Now, I've read a little about pub/sub but never had the opportunity to see it in practice, thus I'd like to understand how to do this using pub/sub. Can you tell me how would that go and how could I get started to implement this solution using it?