fix docker

This commit is contained in:
Wingysam 2019-08-19 10:49:21 -04:00
parent 1054974198
commit c9916333c9
4 changed files with 17 additions and 3 deletions

View file

@ -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
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

View file

@ -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),

View file

@ -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();

View file

@ -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({