added deploying a docker image to docker hub
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
PORT=8080
|
||||
CONNECTION_URI=your_mongodb_connection_uri
|
||||
NODE_ENV="development"
|
||||
@@ -1,9 +1,7 @@
|
||||
const CONNECTION_URI = require('../credentials.js');
|
||||
|
||||
module.exports = function (mongoose) {
|
||||
mongoose.set('useFindAndModify', false);
|
||||
mongoose
|
||||
.connect(CONNECTION_URI, {
|
||||
.connect(process.env.CONNECTION_URI, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
dbName: 'test',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const session = require('express-session');
|
||||
const CONNECTION_URI = require('../credentials.js');
|
||||
const MongoDBStore = require('connect-mongodb-session')(session);
|
||||
|
||||
const store = new MongoDBStore({
|
||||
uri: CONNECTION_URI,
|
||||
uri: process.env.CONNECTION_URI,
|
||||
collection: 'sessions',
|
||||
});
|
||||
const sessionMiddleware = session({
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
// Write your own mongoDBatlas credentials here
|
||||
module.exports = '';
|
||||
Generated
+17
@@ -10,6 +10,7 @@
|
||||
"connect-mongodb-session": "^3.1.1",
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.17.1",
|
||||
"express-session": "^1.17.1",
|
||||
"mongoose": "^5.12.0",
|
||||
@@ -708,6 +709,17 @@
|
||||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
@@ -3157,6 +3169,11 @@
|
||||
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
|
||||
"dev": true
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "16.3.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
|
||||
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
|
||||
},
|
||||
"ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"connect-mongodb-session": "^3.1.1",
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.17.1",
|
||||
"express-session": "^1.17.1",
|
||||
"mongoose": "^5.12.0",
|
||||
|
||||
+7
-4
@@ -1,10 +1,12 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const path = require('path');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const mongoose = require('mongoose');
|
||||
require('dotenv').config();
|
||||
const { sessionMiddleware } = require('./config/session');
|
||||
|
||||
const PORT = 8080;
|
||||
const PORT = process.env.PORT;
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -30,9 +32,10 @@ require('./config/database')(mongoose);
|
||||
require('./config/socket')(server);
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
app.use(express.static('/app/build'));
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile('/app/build/index.html');
|
||||
app.use(express.static('./build'));
|
||||
app.get('*', (req, res) => {
|
||||
const indexPath = path.join(__dirname, './build/index.html');
|
||||
res.sendFile(indexPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user