diff --git a/.envdev b/.envdev index 9d802a6..843664a 100644 --- a/.envdev +++ b/.envdev @@ -5,6 +5,8 @@ WEB_PORT=3200 WEB_ORIGIN=http://localhost:3001 DB_HOSTNAME=localhost +DB_PORTNAME=3306 + DB_DATABASE=auth DB_USERNAME=auth DB_PASSWORD=charizard diff --git a/configure-script.js b/configure-script.js index ddd382c..be979bc 100644 --- a/configure-script.js +++ b/configure-script.js @@ -36,6 +36,25 @@ const question = (prompt, def = null) => { const resetAddress = await question('Reset Addr', `example.com/reset`); const appPort = await question('App Port', '3200'); + //configure the database address + let dbLocation = ''; + while (typeof dbLocation != 'string' || /^[le]/i.test(dbLocation[0]) == false) { + dbLocation = await question('[l]ocal or [e]xternal database?'); + } + + let appDBHost = ''; + let appDBPort = ''; + + if (/^[l]/i.test(dbLocation[0])) { + appDBHost = 'database'; + appDBPort = '3306'; + } + else { + appDBHost = await question('DB Host'); + appDBPort = await question('DB Port', '3306'); + } + + //configure the database account const appDBUser = await question('DB User', appName); const appDBPass = await question('DB Pass', 'charizard'); const dbRootPass = await question('DB Root Pass'); @@ -76,7 +95,8 @@ services: - HOOK_POST_VALIDATION_ARRAY=${postValidationHookArray} - WEB_RESET_ADDRESS=${resetAddress} - WEB_PORT=${appPort} - - DB_HOSTNAME=database + - DB_HOSTNAME=${appDBHost} + - DB_PORTNAME=${appDBPort} - DB_DATABASE=${appName} - DB_USERNAME=${appDBUser} - DB_PASSWORD=${appDBPass} @@ -90,13 +110,14 @@ services: - SECRET_ACCESS=${appSecretAccess} - SECRET_REFRESH=${appSecretRefresh} networks: - - app-network + - app-network${ appDBHost != 'database' ? '' : ` depends_on: - database database: image: mariadb:latest environment: MYSQL_DATABASE: ${appName} + MYSQL_TCP_PORT: ${appDBPort} MYSQL_USER: ${appDBUser} MYSQL_PASSWORD: ${appDBPass} MYSQL_ROOT_PASSWORD: ${dbRootPass} @@ -104,7 +125,7 @@ services: - app-network volumes: - ./mysql:/var/lib/mysql - - ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro + - ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro`} traefik_${appName}: container_name: ${appName}_traefik image: "traefik:v2.10" diff --git a/package-lock.json b/package-lock.json index 04bada7..23bc5df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "auth-server", "version": "1.8.7", - "license": "ISC", + "license": "Zlib", "dependencies": { "bcryptjs": "^2.4.3", "cookie-parser": "^1.4.6", @@ -60,7 +60,8 @@ "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true }, "node_modules/accepts": { "version": "1.3.8", @@ -95,7 +96,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/bcryptjs": { "version": "2.4.3", @@ -141,6 +143,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -216,7 +219,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/content-disposition": { "version": "0.5.4", @@ -857,6 +861,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -989,6 +994,7 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dev": true, "dependencies": { "abbrev": "1" }, diff --git a/package.json b/package.json index 66cf438..a94bb9a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "url": "git+https://github.com/krgamestudios/auth-server.git" }, "author": "Kayne Ruse", - "license": "ISC", + "license": "Zlib", "bugs": { "url": "https://github.com/krgamestudios/auth-server/issues" }, diff --git a/server/database/index.js b/server/database/index.js index d098b9f..9f9611c 100644 --- a/server/database/index.js +++ b/server/database/index.js @@ -2,11 +2,10 @@ const Sequelize = require('sequelize'); const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME, process.env.DB_PASSWORD, { host: process.env.DB_HOSTNAME, + port: process.env.DB_PORTNAME, dialect: 'mariadb', timezone: process.env.DB_TIMEZONE, logging: process.env.DB_LOGGING ? console.log : false }); -sequelize.sync(); - module.exports = sequelize; \ No newline at end of file diff --git a/server/server.js b/server/server.js index 4ed2fab..dae38aa 100644 --- a/server/server.js +++ b/server/server.js @@ -41,4 +41,5 @@ app.get('*', (req, res) => { server.listen(process.env.WEB_PORT || 3200, async (err) => { await database.sync(); console.log(`listening to localhost:${process.env.WEB_PORT || 3200}`); + console.log(`database located at ${process.env.DB_HOSTNAME || ''}:${process.env.DB_PORTNAME || ''}`); });