could you please give me a hint, why this setup is not working?
My frontend docker file gives me suddenly this error. I say suddenly because it was working for a while exactly like that and even more strange is that 2 previous projects working in exact that way:
node:internal/modules/cjs/loader:1222
throw err;
^
Error: Cannot find module '/node usr/src/app/server/main.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15)
at Module._load (node:internal/modules/cjs/loader:1045:27)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
at node:internal/main/run_main_module:30:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
I cant understand this. In my ./frontend folder i do have all the files needed (included the server/main.js). This is mounted into the docker container and then docker tells me it cant find it?!? I have a similar nodeJS Backend which works exactly the same way (see below) and no problem here. In my point of view this error message does not make a bit of sense because all the files are living inside the mounted directory. Please tell me how i could assist you with more information & thanks for any help in advance. BR Marc
services:
traefik:
restart: unless-stopped
image: traefik:latest
ports:
- "80:80"
- "443:443"
- "5000:5000" # frontend
- "8080:8080" # backend
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./acme.json:/acme.json
command:
- --providers.docker.network=proxy
- --providers.docker.exposedByDefault=false
- --entryPoints.web.address=:80
- --entryPoints.web.http.redirections.entryPoint.to=websecure
- --entryPoints.web.http.redirections.entryPoint.scheme=https
- --entryPoints.websecure.address=:443
- --entryPoints.websecure.asDefault=true
- --entryPoints.websecure.http.tls.certResolver=lets-encrypt
- [email protected]
- --certificatesResolvers.lets-encrypt.acme.tlsChallenge=true
- --certificatesResolvers.lets-encrypt.acme.storage=acme.json
frontend:
image: node:latest
command:
- node usr/src/app/server/main.js
volumes:
- ./frontend:/usr/src/app
networks:
- default
- proxy
labels:
- traefik.enable=true
- traefik.http.routers.frontend.rule=Host(`my-domaine.de`)
- traefik.http.routers.frontend.tls=true
- traefik.http.routers.frontend.tls.certresolver=lets-encrypt
- traefik.http.services.frontend.loadbalancer.server.port=5000
networks:
proxy:
external: true
In this nodeJS Backend, the logic is 100% the same and it is working like a charm:
backend:
image: node:latest
container_name: nodeJSBackend
command: node /usr/src/app/index.js
volumes:
- ./backend:/usr/src/app
- ./img:/usr/src/app/img
networks:
- default
- proxy
labels:
- traefik.enable=true
- traefik.http.routers.backend.rule=Host(`backend.my-domain.de`) && ( PathPrefix(`/registerNewPlayer`) || PathPrefix(`/login`) )
- traefik.http.routers.backend.tls=true
- traefik.http.routers.backend.tls.certresolver=lets-encrypt
- traefik.http.services.backend.loadbalancer.server.port=8080
After starting this docker, the node env can find the given index.js and start it. Perfect.
What i also did was restarting docker engine a few times, removed all existing images…did not help. I have also created a brand new VW to see if that was helping. Unfortunately not.
Even more strange is, i have 2 Projects running in the same way and none of these logs throws that the frontend files would miss. Iam so confused from docker.