This commit is contained in:
Wingysam 2019-08-20 08:58:14 -04:00
commit 3045c8db4f
4 changed files with 17 additions and 3 deletions

View file

@ -1,8 +1,21 @@
FROM node:11 FROM node:11
ENV NODE_ENV production ENV NODE_ENV production
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../ RUN npm install --production --silent && mv node_modules ../
COPY . . COPY . .
EXPOSE 3000 EXPOSE 3000
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 CMD npm start

View file

@ -8,6 +8,7 @@ module.exports = {
port: Number(process.env.PORT) || 3000, port: Number(process.env.PORT) || 3000,
proxyServer: process.env.PROXY_SERVER || undefined, proxyServer: process.env.PROXY_SERVER || undefined,
secret: process.env.SECRET || require('./secret'), secret: process.env.SECRET || require('./secret'),
sessionStore: process.env.SESSION_STORE || './sessions',
sessionMaxAge: Number(process.env.SESSION_MAX_AGE) || 1000 * 60 * 60 * 24 * 7, sessionMaxAge: Number(process.env.SESSION_MAX_AGE) || 1000 * 60 * 60 * 24 * 7,
siteTitle: process.env.SITE_TITLE || 'Christmas Community', siteTitle: process.env.SITE_TITLE || 'Christmas Community',
useCDN: yesNo.parse(process.env.USE_CDN || true), useCDN: yesNo.parse(process.env.USE_CDN || true),

View file

@ -2,7 +2,7 @@ const uuid = require('uuid/v4');
const path = require('path'); const path = require('path');
const fs = require('fs'); 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 { try {
module.exports = fs.readFileSync(secretFilePath).toString(); module.exports = fs.readFileSync(secretFilePath).toString();

View file

@ -44,7 +44,7 @@ passport.deserializeUser((user, callback) => {
const LevelStore = expressSessionLevel(session); const LevelStore = expressSessionLevel(session);
const sessionDb = level('./sessions') const sessionDb = level(config.sessionStore)
app.use(require('body-parser').urlencoded({ extended: true })); app.use(require('body-parser').urlencoded({ extended: true }));
app.use(session({ app.use(session({