I am new to Node JS. I have a Node JS + Express app that is causing a Docker container to repeatedly stop with exit code 137 - out of memory error every 5-10 minutes.
The app could not be more simple serving up static html, css, js and images
const express = require('express')
const app = express()
const port = 8080
app.use(express.static('public'))
app.get('/', (req, res) => {
res.sendFile('index.html', { root: __dirname + "/public" } );
})
app.listen(port, () => {
console.log(`web app listening at http://localhost:${port}`)
})
Directory structure
--root
server.js
--public
index.html
--css
--js
--img
The host is an ECS EC2 instance - T2 small with 2Gb memory. The container task allocation 1024 MiB of memory.
Dockerfile
# from nodes 12 image
FROM node:12
MAINTAINER coco
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source - copy all files/folders in current directory
COPY . .
# Specify ports
EXPOSE 8080
# Run the app
CMD [ "node", "server.js" ]
What about this Node app is causing a memory leak? Though, it may be express that's leaking. I'm using
express 4.17.1