I'm trying to deploy a containerized nodejs application to AWS Lambda with Serverless.
It deploys but as soon as I trigger it I'm met with [Error: EROFS: read-only file system, mkdir '/directus/.cache']
, I tried creating the folder and now it's [Error: EROFS: read-only file system, open '.cache/tmp/760261a8']
I know why it is, Lambdas are only writable on /tmp folder, I've search if there is a way to change the location of the node cache, as I assume that it is node because of this line node:internal/process/promises:288
but I found nothing.
Here is the full error:
2023-07-05T17:19:59.015+02:00 node:internal/process/promises:288
2023-07-05T17:19:59.015+02:00 triggerUncaughtException(err, true /* fromPromise */);
2023-07-05T17:19:59.015+02:00 ^
2023-07-05T17:19:59.015+02:00 [Error: EROFS: read-only file system, mkdir '/directus/.cache'] {
2023-07-05T17:19:59.015+02:00 errno: -30,
2023-07-05T17:19:59.015+02:00 code: 'EROFS',
2023-07-05T17:19:59.015+02:00 syscall: 'mkdir',
2023-07-05T17:19:59.015+02:00 path: '/directus/.cache'
2023-07-05T17:19:59.015+02:00 }
2023-07-05T17:19:59.015+02:00 Node.js v18.16.1
2023-07-05T17:19:59.910+02:00 node:internal/process/promises:288
2023-07-05T17:19:59.910+02:00 triggerUncaughtException(err, true /* fromPromise */);
2023-07-05T17:19:59.910+02:00 ^
2023-07-05T17:19:59.910+02:00 [Error: EROFS: read-only file system, mkdir '/directus/.cache'] {
2023-07-05T17:19:59.910+02:00 errno: -30,
2023-07-05T17:19:59.910+02:00 code: 'EROFS',
2023-07-05T17:19:59.910+02:00 syscall: 'mkdir',
2023-07-05T17:19:59.910+02:00 path: '/directus/.cache'
2023-07-05T17:19:59.910+02:00 }
2023-07-05T17:19:59.910+02:00 Node.js v18.16.1
2023-07-05T17:19:59.935+02:00 START RequestId: 46921599-988b-4341-9198-62c8e646ed83 Version: $LATEST
2023-07-05T17:19:59.936+02:00 RequestId: 46921599-988b-4341-9198-62c8e646ed83 Error: Runtime exited with error: exit status 1 Runtime.ExitError
2023-07-05T17:19:59.936+02:00 END RequestId: 46921599-988b-4341-9198-62c8e646ed83
2023-07-05T17:19:59.936+02:00 REPORT RequestId: 46921599-988b-4341-9198-62c8e646ed83 Duration: 859.43 ms Billed Duration: 860 ms Memory Size: 1024 MB Max Memory Used: 30 MB
I'm not experienced enough in nodejs to know what to do now, any help?.
The application is Directus, I know it is not made for Lambdas, but I figured with containers it should work, I was just giving it a try and find it weird to be stuck on this error.
I"ve search for the location of the error in the code to no avail. Tried changing the whole project to /tmp, and surprise surprise, it's not able to run because /tmp gets deleted. (duh)
I've tried the following env vars:
npm_config_cache="/tmp/.npm" \
NODE_CACHE="/tmp/.cache" \
https://github.com/directus/directus in here is pretty much the same Dockerfile that I use