Very new to Docker but When trying to run the container after building I get the following error, has anyone ran into this before?
'internal/modules/cjs/loader.js:905
throw err;'
^
'Error: Cannot find module '/home/backend/dist/src/server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []'
I have built without docker and seems to work fine I run the following commands against the dockerfile (below):
docker build -t [name] .
docker run [name]
FROM node:14.17.1 as base
WORKDIR /home/backend
//Add package file
COPY package.json ./
COPY yarn.lock ./
//Install deps
RUN yarn install
//Copy source
COPY src ./src
COPY tsconfig.json ./tsconfig.json
//Build dist
RUN yarn build
//Start production image build
FROM gcr.io/distroless/nodejs:14
//Copy node modules and build directory
COPY --from=base /home/backend/dist ./home/backend/dist
//Expose port 5000
EXPOSE 5000
CMD [ "/home/backend/dist/src/server.js" ]