I have developed an API using express js that works fine. I use VS code and start the app by doing "node app.js" in terminal. I now want to deploy this api on a server using docker. I have followed this guide: https://github.com/nodejs/docker-node/blob/main/README.md#how-to-use-this-image and I am using the docker-compose option. The docker-compose.yml:
version: "2"
services:
node:
image: "node:current-alpine3.12"
user: "node"
working_dir: /home/node/app
environment:
- NODE_ENV=production
volumes:
- ./node:/home/node/app
expose:
- "80"
command: "npm start"
I have copied all files from my VS code project using scp to the ./node folder mentioned in the docker file. I then get this error when running docker-compose up:
TypeError: app.set is not a function
at Object.<anonymous> (/home/node/app/bin/www:16:5)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
Node.js v17.2.0
npm notice
npm notice New minor version of npm available! 8.1.4 -> 8.2.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.2.0>
npm notice Run `npm install -g npm@8.2.0` to update!
npm notice
In my app.js I do not use app.set. I read about someone else having issues when setting port. I use app.listen(80, () => console.log("Listening on port 80")); to set the correct port. I am not sure why I get an app.set error. How do I fix this issue?