diff --git a/Dockerfile b/Dockerfile index 43f5b69..e283912 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,18 @@ -FROM keymetrics/pm2:latest-alpine +FROM node:18 -# Bundle APP files -COPY src src/ -COPY package.json . -COPY pm2.json . +# Create app directory +WORKDIR /usr/src/app # Install app dependencies -ENV NPM_CONFIG_LOGLEVEL warn -RUN npm install --production +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ -# Show current folder structure in logs -RUN ls -al -R +RUN npm install +# If you are building your code for production +# RUN npm ci --only=production -CMD [ "pm2-runtime", "start", "pm2.json" ] +# Bundle app source +COPY . . + +CMD [ "node", "src/bin/www" ] diff --git a/pm2.json b/pm2.json index 4109d6e..3ce2555 100644 --- a/pm2.json +++ b/pm2.json @@ -1,7 +1,7 @@ { "name": "ushio-session", "script": "src/bin/www", - "instances": "2", + "instances": "1", "env": { "NODE_ENV": "development" }, diff --git a/src/app.js b/src/app.js index a9ee59b..4d31e01 100644 --- a/src/app.js +++ b/src/app.js @@ -6,7 +6,7 @@ var cookieParser = require('cookie-parser'); var logger = require('morgan'); var expressWs = require('express-ws'); -var indexRouter = require('./routes/index'); +var indexRouter = require(__dirname+'/routes/index'); //var usersRouter = require('./routes/users'); var app = express(); diff --git a/src/bin/www b/src/bin/www index 83706e9..a23bb46 100755 --- a/src/bin/www +++ b/src/bin/www @@ -4,7 +4,7 @@ * Module dependencies. */ -var app = require('../app'); +var app = require(__dirname+'/../app'); var debug = require('debug')('ushio-session:server'); var http = require('http');