Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

Docker image does not launch node web app

$
0
0

Trying to follow this tutorial from MS but I keep getting "This page isn't working" error. Is there something wrong with the index.js file that is causing the page to not come up? Here is the repo with the starter files.

The Dockerfile used to build the image:

FROM node:12-alpineWORKDIR /appCOPY . .RUN yarn install --productionCMD ["node", "/app/src/index.js"]

The index.js:

const express = require('express');const app = express();const db = require('./persistence');const getItems = require('./routes/getItems');const addItem = require('./routes/addItem');const updateItem = require('./routes/updateItem');const deleteItem = require('./routes/deleteItem');app.use(express.json());app.use(express.static(__dirname +'/static'));app.get('/items', getItems);app.post('/items', addItem);app.put('/items/:id', updateItem);app.delete('/items/:id', deleteItem);db.init().then(() => {    app.listen(3000, () => console.log('Listening on port 3000'));}).catch((err) => {    console.error(err);    process.exit(1);});const gracefulShutdown = () => {    db.teardown()        .catch(() => {})        .then(() => process.exit());};process.on('SIGINT', gracefulShutdown);process.on('SIGTERM', gracefulShutdown);process.on('SIGUSR2', gracefulShutdown); // Sent by nodemon

The command I used to run the container:

docker run -dp 3000:3000 getting-started

Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>