1

i'm trying to launch a nodejs container using AWS FARGATE, the problem i'm facing is that fargate gives me this error :

cannot find this module "/path/to/file/webrtc.js"

And when i execute npm install from the command section when launching the container it gives me

npm WARN enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
npm WARN saveError EACCES: permission denied, open '/usr/src/app/package-lock.json.12345678'
npm WARN saveError ENOENT: no such file or directory, open '/usr/src/app/package.json'

How to give permission ? I tried changing the json file and swapping user = null with user = root, but same error appears.

thank you,

Greg Askew
  • 34,339
  • 3
  • 52
  • 81
logax
  • 99
  • 1
  • 14

1 Answers1

1

You should build the container in such a way that it works right after starting without executing extra commands.

Maybe a tutorial on Dockerizing node.js apps may come handy for start.

Hope that helps :)

MLu
  • 23,798
  • 5
  • 54
  • 81
  • Hi, Thank you for commenting, ok, so i figured that i don't have to cmd npm commands in the container but there is one last thing that needs to be done, which is this : ``` CMD [ "node", "server.js" ] ``` How to run this in the fargate, it exists in the image but will fargate be able to use it without me explicitly putting it ? – logax Aug 24 '20 at 16:47
  • If you do `docker run --rm -it yourimage` locally on your laptop does it work and does it do what you want? If not then it won’t work in Fargate either. Make sure your docker image is built correctly and verify it locally before running it in Fargate. – MLu Aug 24 '20 at 20:59
  • i'm just starting to use docker, so i'm not very familiar with it, we used docker-compose to run the image, and it runs perfectly fine, i don't know why it gives me errors when using it on fargate. – logax Aug 25 '20 at 10:05
  • Is it possible to merge what we have in docker-compose to the docker file ? – logax Aug 25 '20 at 15:44
  • Possibly. Depends what your docker-compose.yml contains. Post it to your question. – MLu Aug 25 '20 at 21:07
  • Sorry for the late response, Here it is : version: '2' services: project: image: imagename volumes: - /etc/files/:/etc/files/ ports: - "${PORT}:10000" - 3000-4000:3000-4000/tcp environment: - HTTPS_PRIVATEKEY - HTTPS_CERTIFICATE - HTTPS_CA - IP - URL I used the efs service of aws to mimick the function of the volume and i also inserted the env variables in fargate, but to no avail. – logax Aug 27 '20 at 17:04