After successfully building with the dockerfile provided below, I encountered an issue when trying to deploy my application on EKS.
FROM node:12
# Create app directory
WORKDIR /usr/src/app
COPY udagram-feed/package*.json ./
RUN npm ci
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "npm", "run", "prod" ]
Upon checking the cluster logs, I received the following error message:
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '/usr/src/app/www/server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prod: `tsc && node ./www/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-20T19_11_45_220Z-debug.log
When testing the image locally, the file structure is as follows:
- Dockerfile
- node_modules
- package.json
- package-lock.json
- src
The src/ directory contains the serves.ts sequelize.ts and other files. It is apparent that there is no www/ directory. Why is Kubernetes looking for files in this directory? Any assistance would be greatly appreciated. I have been struggling with this issue for days now and am unsure of what steps to take next. For the file structure, please refer to the GitHub repository GitHub