UNTESTED: Added database port as a configurable option
Also updated license field in package.json
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
WEB_PORT=3000
|
WEB_PORT=3000
|
||||||
|
|
||||||
DB_HOSTNAME=localhost
|
DB_HOSTNAME=localhost
|
||||||
|
DB_PORTNAME=3306
|
||||||
|
|
||||||
DB_DATABASE=template
|
DB_DATABASE=template
|
||||||
DB_USERNAME=template
|
DB_USERNAME=template
|
||||||
DB_PASSWORD=pikachu
|
DB_PASSWORD=pikachu
|
||||||
|
|||||||
+94
-19
@@ -36,7 +36,7 @@ const question = (prompt, def = null) => {
|
|||||||
|
|
||||||
Currently, all microservices are mandatory; you'll have to mess with the result
|
Currently, all microservices are mandatory; you'll have to mess with the result
|
||||||
and the source code if you wish to be more selective. Microservices currently
|
and the source code if you wish to be more selective. Microservices currently
|
||||||
impelented are:
|
implemented are:
|
||||||
|
|
||||||
* auth-server
|
* auth-server
|
||||||
* news-server
|
* news-server
|
||||||
@@ -49,7 +49,7 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
|||||||
//determine local computer address for mac user vs everyone else
|
//determine local computer address for mac user vs everyone else
|
||||||
let macUser = '';
|
let macUser = '';
|
||||||
while (macUser.toLowerCase() !== 'yes' && macUser.toLowerCase() !== 'no') {
|
while (macUser.toLowerCase() !== 'yes' && macUser.toLowerCase() !== 'no') {
|
||||||
macUser = await question('Will the MERN Template be running locally on a MacOS system? (yes or no)', '');
|
macUser = await question('Will the MERN-Template be running locally on a MacOS system? (yes or no, this only alters startup.sql)', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const localAddress = macUser ? 'localhost' : '%';
|
const localAddress = macUser ? 'localhost' : '%';
|
||||||
@@ -58,13 +58,48 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
|||||||
const projectName = await question('Project Name', 'template');
|
const projectName = await question('Project Name', 'template');
|
||||||
const projectWebAddress = await question('Project Web Address', 'example.com');
|
const projectWebAddress = await question('Project Web Address', 'example.com');
|
||||||
|
|
||||||
|
let projectDBLocation = '';
|
||||||
|
while (typeof projectDBLocation != 'string' || /^[le]/i.test(projectDBLocation[0]) == false) {
|
||||||
|
projectDBLocation = await question('Project [l]ocal or [e]xternal database?');
|
||||||
|
}
|
||||||
|
|
||||||
|
let projectDBHost = '';
|
||||||
|
let projectDBPort = '';
|
||||||
|
|
||||||
|
if (/^[l]/i.test(projectDBLocation[0])) {
|
||||||
|
projectDBHost = 'database';
|
||||||
|
projectDBPort = '3306';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
projectDBHost = await question('Project DB Host');
|
||||||
|
projectDBPort = await question('Project DB Port', '3306');
|
||||||
|
}
|
||||||
|
|
||||||
const projectDBUser = await question('Project DB Username', projectName);
|
const projectDBUser = await question('Project DB Username', projectName);
|
||||||
const projectDBPass = await question('Project DB Password', 'pikachu');
|
const projectDBPass = await question('Project DB Password', 'pikachu');
|
||||||
|
|
||||||
//news configuration
|
//news configuration
|
||||||
const newsName = await question('News Name', 'news');
|
const newsName = await question('News Name', 'news');
|
||||||
const newsWebAddress = await question('News Web Address', `${newsName}.${projectWebAddress}`);
|
const newsWebAddress = await question('News Web Address', `${newsName}.${projectWebAddress}`);
|
||||||
const newsDBUser = await question('News DB Username', newsName);
|
|
||||||
|
let newsDBLocation = '';
|
||||||
|
while (typeof newsDBLocation != 'string' || /^[le]/i.test(newsDBLocation[0]) == false) {
|
||||||
|
newsDBLocation = await question('News [l]ocal or [e]xternal database?');
|
||||||
|
}
|
||||||
|
|
||||||
|
let newsDBHost = '';
|
||||||
|
let newsDBPort = '';
|
||||||
|
|
||||||
|
if (/^[l]/i.test(newsDBLocation[0])) {
|
||||||
|
newsDBHost = 'database';
|
||||||
|
newsDBPort = '3306';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newsDBHost = await question('News DB Host');
|
||||||
|
newsDBPort = await question('News DB Port', '3306');
|
||||||
|
}
|
||||||
|
|
||||||
|
const newsDBUser = await question('News DB Username', newsName);
|
||||||
const newsDBPass = await question('News DB Password', 'venusaur');
|
const newsDBPass = await question('News DB Password', 'venusaur');
|
||||||
|
|
||||||
//auth configuration
|
//auth configuration
|
||||||
@@ -72,7 +107,25 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
|||||||
const authWebAddress = await question('Auth Web Address', `${authName}.${projectWebAddress}`);
|
const authWebAddress = await question('Auth Web Address', `${authName}.${projectWebAddress}`);
|
||||||
const authPostValidationHookArray = await question('Auth Post Validation Hook Array', '');
|
const authPostValidationHookArray = await question('Auth Post Validation Hook Array', '');
|
||||||
const authResetAddress = await question('Auth Reset Addr', `${projectWebAddress}/reset`);
|
const authResetAddress = await question('Auth Reset Addr', `${projectWebAddress}/reset`);
|
||||||
const authDBUser = await question('Auth DB Username', authName);
|
|
||||||
|
let authDBLocation = '';
|
||||||
|
while (typeof authDBLocation != 'string' || /^[le]/i.test(authDBLocation[0]) == false) {
|
||||||
|
authDBLocation = await question('Auth [l]ocal or [e]xternal database?');
|
||||||
|
}
|
||||||
|
|
||||||
|
let authDBHost = '';
|
||||||
|
let authDBPort = '';
|
||||||
|
|
||||||
|
if (/^[l]/i.test(authDBLocation[0])) {
|
||||||
|
authDBHost = 'database';
|
||||||
|
authDBPort = '3306';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
authDBHost = await question('Auth DB Host');
|
||||||
|
authDBPort = await question('Auth DB Port', '3306');
|
||||||
|
}
|
||||||
|
|
||||||
|
const authDBUser = await question('Auth DB Username', authName);
|
||||||
const authDBPass = await question('Auth DB Password', 'charizard');
|
const authDBPass = await question('Auth DB Password', 'charizard');
|
||||||
|
|
||||||
const emailSMTP = await question('Email SMTP', 'smtp.example.com');
|
const emailSMTP = await question('Email SMTP', 'smtp.example.com');
|
||||||
@@ -83,7 +136,25 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
|||||||
//chat goes here
|
//chat goes here
|
||||||
const chatName = await question('Chat Name', 'chat');
|
const chatName = await question('Chat Name', 'chat');
|
||||||
const chatWebAddress = await question('Chat Web Address', `${chatName}.${projectWebAddress}`);
|
const chatWebAddress = await question('Chat Web Address', `${chatName}.${projectWebAddress}`);
|
||||||
const chatDBUser = await question('Chat DB Username', chatName);
|
|
||||||
|
let chatDBLocation = '';
|
||||||
|
while (typeof chatDBLocation != 'string' || /^[le]/i.test(chatDBLocation[0]) == false) {
|
||||||
|
chatDBLocation = await question('Chat [l]ocal or [e]xternal database?');
|
||||||
|
}
|
||||||
|
|
||||||
|
let chatDBHost = '';
|
||||||
|
let chatDBPort = '';
|
||||||
|
|
||||||
|
if (/^[l]/i.test(chatDBLocation[0])) {
|
||||||
|
chatDBHost = 'database';
|
||||||
|
chatDBPort = '3306';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
chatDBHost = await question('Chat DB Host');
|
||||||
|
chatDBPort = await question('Chat DB Port', '3306');
|
||||||
|
}
|
||||||
|
|
||||||
|
const chatDBUser = await question('Chat DB Username', chatName);
|
||||||
const chatDBPass = await question('Chat DB Password', 'blastoise');
|
const chatDBPass = await question('Chat DB Password', 'blastoise');
|
||||||
|
|
||||||
//database configuration
|
//database configuration
|
||||||
@@ -134,7 +205,8 @@ services:
|
|||||||
- traefik.http.services.${projectName}service.loadbalancer.server.port=${projectPort}
|
- traefik.http.services.${projectName}service.loadbalancer.server.port=${projectPort}
|
||||||
environment:
|
environment:
|
||||||
- WEB_PORT=${projectPort}
|
- WEB_PORT=${projectPort}
|
||||||
- DB_HOSTNAME=database
|
- DB_HOSTNAME=${projectDBHost}
|
||||||
|
- DB_PORTNAME=${projectDBPort}
|
||||||
- DB_DATABASE=${projectName}
|
- DB_DATABASE=${projectName}
|
||||||
- DB_USERNAME=${projectDBUser}
|
- DB_USERNAME=${projectDBUser}
|
||||||
- DB_PASSWORD=${projectDBPass}
|
- DB_PASSWORD=${projectDBPass}
|
||||||
@@ -145,8 +217,8 @@ services:
|
|||||||
- SECRET_ACCESS=${accessToken}
|
- SECRET_ACCESS=${accessToken}
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
depends_on:
|
depends_on:${ projectDBHost != 'database' ? '' : `
|
||||||
- database
|
- database`}
|
||||||
- traefik
|
- traefik
|
||||||
|
|
||||||
${newsName}:
|
${newsName}:
|
||||||
@@ -162,7 +234,8 @@ services:
|
|||||||
- traefik.http.services.${newsName}service.loadbalancer.server.port=${newsPort}
|
- traefik.http.services.${newsName}service.loadbalancer.server.port=${newsPort}
|
||||||
environment:
|
environment:
|
||||||
- WEB_PORT=${newsPort}
|
- WEB_PORT=${newsPort}
|
||||||
- DB_HOSTNAME=database
|
- DB_HOSTNAME=${newsDBHost}
|
||||||
|
- DB_PORTNAME=${newsDBPort}
|
||||||
- DB_DATABASE=${newsName}
|
- DB_DATABASE=${newsName}
|
||||||
- DB_USERNAME=${newsDBUser}
|
- DB_USERNAME=${newsDBUser}
|
||||||
- DB_PASSWORD=${newsDBPass}
|
- DB_PASSWORD=${newsDBPass}
|
||||||
@@ -171,8 +244,8 @@ services:
|
|||||||
- SECRET_ACCESS=${accessToken}
|
- SECRET_ACCESS=${accessToken}
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
depends_on:
|
depends_on:${ newsDBHost != 'database' ? '' : `
|
||||||
- database
|
- database`}
|
||||||
- traefik
|
- traefik
|
||||||
|
|
||||||
${authName}:
|
${authName}:
|
||||||
@@ -192,7 +265,8 @@ services:
|
|||||||
- HOOK_POST_VALIDATION_ARRAY=${authPostValidationHookArray}
|
- HOOK_POST_VALIDATION_ARRAY=${authPostValidationHookArray}
|
||||||
- WEB_RESET_ADDRESS=${authResetAddress}
|
- WEB_RESET_ADDRESS=${authResetAddress}
|
||||||
- WEB_PORT=${authPort}
|
- WEB_PORT=${authPort}
|
||||||
- DB_HOSTNAME=database
|
- DB_HOSTNAME=${authDBHost}
|
||||||
|
- DB_PORTNAME=${authDBPort}
|
||||||
- DB_DATABASE=${authName}
|
- DB_DATABASE=${authName}
|
||||||
- DB_USERNAME=${authDBUser}
|
- DB_USERNAME=${authDBUser}
|
||||||
- DB_PASSWORD=${authDBPass}
|
- DB_PASSWORD=${authDBPass}
|
||||||
@@ -207,8 +281,8 @@ services:
|
|||||||
- SECRET_REFRESH=${refreshToken}
|
- SECRET_REFRESH=${refreshToken}
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
depends_on:
|
depends_on:${ authDBHost != 'database' ? '' : `
|
||||||
- database
|
- database`}
|
||||||
- traefik
|
- traefik
|
||||||
|
|
||||||
${chatName}:
|
${chatName}:
|
||||||
@@ -224,7 +298,8 @@ services:
|
|||||||
- traefik.http.services.${chatName}service.loadbalancer.server.port=${chatPort}
|
- traefik.http.services.${chatName}service.loadbalancer.server.port=${chatPort}
|
||||||
environment:
|
environment:
|
||||||
- WEB_PORT=${chatPort}
|
- WEB_PORT=${chatPort}
|
||||||
- DB_HOSTNAME=database
|
- DB_HOSTNAME=${chatDBHost}
|
||||||
|
- DB_PORTNAME=${chatDBPort}
|
||||||
- DB_DATABASE=${chatName}
|
- DB_DATABASE=${chatName}
|
||||||
- DB_USERNAME=${chatDBUser}
|
- DB_USERNAME=${chatDBUser}
|
||||||
- DB_PASSWORD=${chatDBPass}
|
- DB_PASSWORD=${chatDBPass}
|
||||||
@@ -232,10 +307,10 @@ services:
|
|||||||
- SECRET_ACCESS=${accessToken}
|
- SECRET_ACCESS=${accessToken}
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
depends_on:
|
depends_on:${ chatDBHost != 'database' ? '' : `
|
||||||
- database
|
- database`}
|
||||||
- traefik
|
- traefik
|
||||||
|
${ [projectDBHost, newsDBHost, authDBHost, chatDBHost].some(x => x == "database") == false ? '' : `
|
||||||
database:
|
database:
|
||||||
image: mariadb
|
image: mariadb
|
||||||
restart: always
|
restart: always
|
||||||
@@ -246,7 +321,7 @@ services:
|
|||||||
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro
|
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
`}
|
||||||
traefik:
|
traefik:
|
||||||
image: traefik:v2.10
|
image: traefik:v2.10
|
||||||
container_name: traefik
|
container_name: traefik
|
||||||
|
|||||||
Generated
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "mern-template",
|
"name": "mern-template",
|
||||||
"version": "1.5.1",
|
"version": "1.5.1",
|
||||||
"license": "ISC",
|
"license": "Zlib",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.24.4",
|
"@babel/core": "^7.24.4",
|
||||||
"@babel/preset-env": "^7.24.4",
|
"@babel/preset-env": "^7.24.4",
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
"url": "git+https://github.com/KRGameStudios/MERN-template.git"
|
"url": "git+https://github.com/KRGameStudios/MERN-template.git"
|
||||||
},
|
},
|
||||||
"author": "Kayne Ruse",
|
"author": "Kayne Ruse",
|
||||||
"license": "ISC",
|
"license": "Zlib",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/KRGameStudios/MERN-template/issues"
|
"url": "https://github.com/KRGameStudios/MERN-template/issues"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ const Sequelize = require('sequelize');
|
|||||||
|
|
||||||
const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME, process.env.DB_PASSWORD, {
|
const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME, process.env.DB_PASSWORD, {
|
||||||
host: process.env.DB_HOSTNAME,
|
host: process.env.DB_HOSTNAME,
|
||||||
|
port: process.env.DB_PORTNAME,
|
||||||
dialect: 'mariadb',
|
dialect: 'mariadb',
|
||||||
timezone: process.env.DB_TIMEZONE,
|
timezone: process.env.DB_TIMEZONE,
|
||||||
logging: process.env.DB_LOGGING ? console.log : false
|
logging: process.env.DB_LOGGING ? console.log : false
|
||||||
});
|
});
|
||||||
|
|
||||||
sequelize.sync();
|
module.exports = sequelize;
|
||||||
|
|
||||||
module.exports = sequelize;
|
|
||||||
@@ -42,4 +42,5 @@ app.get('*', (req, res) => {
|
|||||||
server.listen(process.env.WEB_PORT || 3000, async (err) => {
|
server.listen(process.env.WEB_PORT || 3000, async (err) => {
|
||||||
await database.sync();
|
await database.sync();
|
||||||
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
|
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
|
||||||
|
console.log(`database located at ${process.env.DB_HOSTNAME || '<default>'}:${process.env.DB_PORTNAME || '<default>'}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user