Details
-
Task
-
Resolution: Works as Designed
-
Major - P3
-
None
-
None
-
None
-
None
Description
In short when running in container on Apple Silicon I receive this error:
```
2023-09-28 09:28:49 /app/node_modules/mongodb/src/encrypter.ts:124
2023-09-28 09:28:49 throw new MongoMissingDependencyError(
2023-09-28 09:28:49 ^
2023-09-28 09:28:49 MongoMissingDependencyError: Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project
2023-09-28 09:28:49 at Function.checkForMongoCrypt (/app/node_modules/mongodb/src/encrypter.ts:124:13)
2023-09-28 09:28:49 at parseOptions (/app/node_modules/mongodb/src/connection_string.ts:443:15)
2023-09-28 09:28:49 at new MongoClient (/app/node_modules/mongodb/src/mongo_client.ts:331:34)
```
This error message is deceptive because, of course dependency is there and when I run without container there is no error
extract from package.json
```
"mongodb-client-encryption": "^6.0.0",
```
The container itself builds from
FROM arm64v8/node:19.9 (which I believe is an ubuntu image)
The difference is in the library that is used
we have the library being chosen dynamally depending on the platform like this:
```
private getAutoEncryptionOptions() {
const autoEncryptionOptions = {
keyVaultNamespace: `${this.dbName}.${MONGODB_KEY_VAULT_COLLECTION}`,
kmsProviders: this.kmsProviders,
extraOptions:
,
};
return autoEncryptionOptions;
}
export const MONGODB_SHARED_LIB_PATH =
process.platform === 'win32'
? 'libs/mongo_crypt_v1.dll'
: process.platform === 'darwin'
? 'libs/mongo_crypt_v1.dylib'
: 'libs/mongo_crypt_v1.so';
```
So when I run directly on mac m1 it picks mongo_crypt_v1.dylib and all runs smoothly. However when I run in container it probably tries to pick mongo_crypt_v1.so. Unfortunatelly, I don't see the exact error - it's just my guess because as I mentioned above the error message is deceptive.
Not being able to use docker on m1 because of encryption is major hurdle. I would like to know whether you may suggest any workaround. How to link the correct library? How to build the correct library in docker from scratch?