Last active
December 16, 2022 21:54
-
-
Save IliasDeros/9d23f55173e6487ecb681caabf596923 to your computer and use it in GitHub Desktop.
Run mongodb in memory on Docker without using TMPFS (https://github.com/docker-library/mongo/issues/224)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MongoMemoryServer } from 'mongodb-memory-server'; | |
// This will create an new instance of "MongoMemoryServer" and automatically start it | |
const mongod = await MongoMemoryServer.create({ | |
instance: { | |
port: 27017, | |
ip: "::,0.0.0.0", | |
dbName: 'in_memory' | |
} | |
}); | |
const uri = mongod.getUri(); | |
console.log("Running in-memory MongoDB on " + uri); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:16 | |
RUN apt-get install libcurl4 | |
WORKDIR /project | |
COPY ./db.mjs /project | |
RUN yarn add mongodb-memory-server | |
ENTRYPOINT ["node", "./in-memory-db.mjs"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment