Comments (18)
So if Mongo team makes alpine build we can easily add it to this package
https://www.mongodb.org/dl/linux
An opened issue in MongoDB: https://jira.mongodb.org/browse/SERVER-36790
from mongodb-memory-server.
I am using this image. It is an image that I have created with the needed environment variables built right in. It is quite fast since it doesn't need any binaries to be downloaded and is only 158 MB. Here is the Dockerfile. Enjoy!
from mongodb-memory-server.
Can you take a look on https://github.com/nodkz/mongodb-memory-server/blob/master/src/util/MongoBinaryDownloadUrl.js and test for this file.
Will be awsome if you make Pull Request with fixing this error.
Thanks for help!
from mongodb-memory-server.
I'll check later, temporarily switched to docker image with mongo, need to finish my project first.
from mongodb-memory-server.
@Kostanos What image did you end up going with?
from mongodb-memory-server.
FYI for anyone running into this issue -- switching from the nodejs alpine image to the nodejs debian stretch image solved this for me (albeit with a MUCH larger image).
I'm getting an ENOENT error with the alpine image. This sums up why: https://stackoverflow.com/questions/32724556/execute-mongodb-binaries-on-alpine-linux
from mongodb-memory-server.
At present it seems unlikely that MongoDB is going to release a separate Alpine Linux binary themselves. From their official documentation they direct users to the Alpine Linux mongodb package.
I would suggest that users who want to run their tests inside of an Alpine Linux container either add the specifically mentioned packages to their Dockerfile
or base their container on something like the alpine-mongo container that is already available on Docker Hub.
from mongodb-memory-server.
@jloveridge, you mention that I could use the apline-mongo image to run my tests but it still tries to download binaries inside that image (which it can't do since there aren't any official binaries...) is there a way (perhaps a combo of ENV vars) to tell mongodb-memory-server to use the installed system binaries instead of trying to download anything?
from mongodb-memory-server.
@jtbairdsr needs to create such var ;) Good feature request!
Firstly we should decide which name should have ENV variable which will point on the local installed mongod path. Currently available options are
binary: {
version?: string, // by default 'latest'
downloadDir?: string, // by default node_modules/.cache/mongodb-memory-server/mongodb-binaries
platform?: string, // by default os.platform()
arch?: string, // by default os.arch()
debug?: boolean, // by default false
skipMD5?: boolean, // by default false OR process.env.MONGOMS_SKIP_MD5_CHECK
},
Then improve getPath
method: https://github.com/nodkz/mongodb-memory-server/blob/master/src/util/MongoBinary.js#L26 with such logic:
- check local binary provided via the new a var
- if var non-empty
- check path availability and return it
- if not available drop a warning to console and run standard code (with download/cache)
- if var empty
- just run current standard code
Also, it should have different var names according to the current environment Mac, Linux or Win.
Or maybe it should be an array of paths for any OS. I think that the array of paths is more preferable.
Thougts?
from mongodb-memory-server.
@nodkz I don't know if I understand why we need different vars for each environment. This is one of those things that the environment is going to know about (a Mac environment will only know about its own path). If the path is different on a windows machine then on Mac, that should be reflected in the contents of the variable not in the name of the variable...
currently we pull the same variable regardless of the OS for all other env variables so I think that we should follow that same pattern...
some ideas for variable names are
systemBinary
-process.env.MONGOMS_SYSTEM_BINARY
systemBin
-process.env.MONGOMS_SYSTEM_BIN
sysBin
-process.env.MONGOMS_SYS_BIN
bin
-process.env.MONGOMS_BIN
if we really need to provide a different var for each OS, we could use the os as a key to get the correct path from the variable which would make it fairly simple to consume...
// binary.systemBinary = { darwin: '/usr/bin/mongod', debian: '/usr/local/bin/mongod' }
systemBinaryPath = binary.systemBinary[os.platform()]
// systemBinaryPath === '/usr/ bin/mongod'
we could maybe even provide a default config that knows where the default install is for each system (or at least some common systems like Mac and windows and linux) so that if it is available we consume the system binaries by default (although that seams like a lot of maintenance to me)
from mongodb-memory-server.
my next question is what do we do about version if a system binary is provided... Do we discard any version info passed? Do we try and check the system binary for version and see if they match? Do we discard system binary in favor of version? Do we just log that we have both settings and what there values are and then proceed with the system version?
I think I prefer the last option. Something like...
console.log(`
MongoMemoryServer: Possible version conflict
SystemBinary version: ${execSync('mongod --version')}
Requested version: ${binary.version}
`)
and then continue with the system version.
This last option lets the user decide how exact they want the match to be (if it needs to match on Major and minor and patch of just Major and minor or just Major etc.)
I also saves us from having to identify version matching edge cases...
from mongodb-memory-server.
I have attempted the change to the getPath
method on my fork here and here if you care to take a look.
If you like what you see I would be happy to create a pull request.
from mongodb-memory-server.
@jtbairdsr open PR and let make it better via several iterations.
Firstly we should split getPath
method into several methods. And avoid using the hacking assignment of this.cache[version]
to systemBinary
. It will produce errors in the future, cause we make cache
variable unobvious.
from mongodb-memory-server.
@nodkz I agree... here is the PR #119
from mongodb-memory-server.
Docker Alpine
There isn't currently an official MongoDB release for alpine linux. This means that we can't pull binaries for Alpine (or any other platform that isn't officially supported by MongoDB), but you can use a Docker image that already has mongod built in and then set the MONGOMS_SYSTEM_BINARY
variable to point at that binary. This should allow you to use mongodb-memory-server on any system on which you can install mongod.
All credits to @jtbairdsr for the excellent solution for the current problem!
PS. @jtbairdsr can you add a link for the recommended Docker container to README.md It helps to save time for many developers. Thanks again for amazing PR!
from mongodb-memory-server.
@jtbairdsr even more with provided image you can share your existed solution with docker file or bash command.
from mongodb-memory-server.
hello team,
I can't seem to figure out why this is happening, is this related to the environment I am currently using?
from mongodb-memory-server.
is this related to the environment I am currently using?
as per the documentation (and this issue's closing comment):
There are no official mongodb builds alpine, though there are some unoffical build of mongodb build for it which can be used
and there is #347
if you cant figure out why you are using alpine, please open a discussion or ask on our discord server.
from mongodb-memory-server.
Related Issues (20)
- postinstallHelper always installs to $HOME/.cache instead of node_modules/.cache HOT 6
- Enabling debug mode through package.json does not work HOT 3
- Randomizing db names for each test
- GridFS streams not working correctly HOT 4
- Jest + mongodb-memory-server + mongoose - Calling 'find' hangs indefinitely HOT 2
- Invalid version reported for version strings ending in -latest HOT 2
- Ubuntu >= 22.04 is unsupported when using MongoDB >= 6.0.4 HOT 7
- _startUpInstance threw a Error: TypeError: (intermediate value).finally is not a function HOT 3
- Mongod instance closed with code "127" HOT 7
- Case: InMemory DB refuses to update after Making changes to model HOT 7
- Library is missing or cannot be opened: "libcrypto.so.1.1" HOT 2
- 9.1.8 not working out of the box for node:20 docker (LTS images) HOT 5
- ReplicaSet - emulate replication lag HOT 1
- Issue downloading mongo binaries with Nexus set as MONGOMS_DOWNLOAD_MIRROR HOT 8
- Error when trying to run tests HOT 1
- Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1" HOT 8
- Requested Version "6.0.14" is not available for "Debian 12"! Available Versions: ">=7.0.3" HOT 1
- Mongod sometimes fails to start due to ETXTBSY HOT 10
- The download of the mongodb binary is corrupted when using a hoisted dependency in a monorepo HOT 4
- How to initialize data/collections/indexes on startup? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-memory-server.