From 1054974198cc50d12b7aa7bfea6357801d61aa9f Mon Sep 17 00:00:00 2001 From: Wingysam Date: Mon, 19 Aug 2019 10:49:14 -0400 Subject: [PATCH 1/2] update get-product-name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21937de..24bc814 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "express": "^4.16.4", "express-session": "^1.15.6", "express-session-level": "^1.0.0", - "get-product-name": "^1.*", + "get-product-name": "^1.2.2", "level": "^4.0.0", "passport": "^0.4.0", "passport-local": "^1.0.0", From c9916333c9364e43356892fbf9a5aded3c89966b Mon Sep 17 00:00:00 2001 From: Wingysam Date: Mon, 19 Aug 2019 10:49:21 -0400 Subject: [PATCH 2/2] fix docker --- Dockerfile | 15 ++++++++++++++- config/index.js | 1 + config/secret/index.js | 2 +- index.js | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c587345..d97e437 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,21 @@ FROM node:11 + ENV NODE_ENV production WORKDIR /usr/src/app + COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] RUN npm install --production --silent && mv node_modules ../ + COPY . . + EXPOSE 3000 -CMD npm start \ No newline at end of file + +RUN mkdir -p /data/db +ENV DB_URL /data/db + +RUN mkdir -p /data/sessions +ENV SESSION_STORE /data/sessions + +ENV SECRET_DIRNAME /data + +CMD npm start diff --git a/config/index.js b/config/index.js index 95be6a3..25c0cce 100644 --- a/config/index.js +++ b/config/index.js @@ -8,6 +8,7 @@ module.exports = { port: Number(process.env.PORT) || 3000, proxyServer: process.env.PROXY_SERVER || undefined, secret: process.env.SECRET || require('./secret'), + sessionStore: process.env.SESSION_STORE || './sessions', sessionMaxAge: Number(process.env.SESSION_MAX_AGE) || 1000 * 60 * 60 * 24 * 7, siteTitle: process.env.SITE_TITLE || 'Christmas Community', useCDN: yesNo.parse(process.env.USE_CDN || true), diff --git a/config/secret/index.js b/config/secret/index.js index dabdf94..ba422a2 100644 --- a/config/secret/index.js +++ b/config/secret/index.js @@ -2,7 +2,7 @@ const uuid = require('uuid/v4'); const path = require('path'); const fs = require('fs'); -const secretFilePath = path.join(__dirname, 'secret.txt'); +const secretFilePath = path.join((process.env.SECRET_DIRNAME ? process.env.SECRET_DIRNAME : __dirname), 'secret.txt'); try { module.exports = fs.readFileSync(secretFilePath).toString(); diff --git a/index.js b/index.js index 228e8aa..a280287 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,7 @@ passport.deserializeUser((user, callback) => { const LevelStore = expressSessionLevel(session); -const sessionDb = level('./sessions') +const sessionDb = level(config.sessionStore) app.use(require('body-parser').urlencoded({ extended: true })); app.use(session({