diff --git a/cts/.env.example b/cts/.env.example index c386f6e..f78403f 100644 --- a/cts/.env.example +++ b/cts/.env.example @@ -1,5 +1,10 @@ HOSTNAME=localhost +DB_HOST=rdbms +DB_NAME=catapult_player +DB_USERNAME=catapult +DB_PASSWORD=quartz + PLAYER_ROOT_PATH=/player PLAYER_BASE_URL=http://player:3398/player PLAYER_CONTENT_URL=http://localhost/player/content diff --git a/cts/docker-compose.yml b/cts/docker-compose.yml index 6bd94f2..61ed419 100644 --- a/cts/docker-compose.yml +++ b/cts/docker-compose.yml @@ -60,9 +60,13 @@ services: - ./seeds:/usr/src/app/seeds:ro environment: - HOSTNAME - - DATABASE_USER=catapult - - DATABASE_USER_PASSWORD=quartz - - DATABASE_NAME=catapult_cts + - DB_HOST + - DB_NAME + - DB_USERNAME + - DB_PASSWOD + # - DATABASE_USER=catapult + # - DATABASE_USER_PASSWORD=quartz + # - DATABASE_NAME=catapult_cts - PLAYER_BASE_URL - PLAYER_KEY - PLAYER_SECRET diff --git a/cts/service/index.js b/cts/service/index.js index 5dd3015..dd4a448 100644 --- a/cts/service/index.js +++ b/cts/service/index.js @@ -65,7 +65,8 @@ const provision = async () => { } }; - await waitPort({host: "rdbms", port: 3306}); + const DB_HOST = (process.env.DB_HOST || "rdbms"); + await waitPort({host: DB_HOST, port: 3306}); const db = await require("./lib/db")(); diff --git a/cts/service/knexfile.js b/cts/service/knexfile.js index d217bfe..e90945f 100644 --- a/cts/service/knexfile.js +++ b/cts/service/knexfile.js @@ -13,24 +13,33 @@ See the License for the specific language governing permissions and limitations under the License. */ +const DB_HOST = (process.env.DB_HOST || "rdbms"); +const DB_NAME = (process.env.DB_NAME || "catapult_player"); +const DB_USERNAME = (process.env.DB_USERNAME || "catapult"); +const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz"); + const Hoek = require("@hapi/hoek"), waitPort = require("wait-port"), { - MYSQL_HOST: HOST = "rdbms", + // MYSQL_HOST: HOST = "rdbms", MYSQL_HOST_FILE: HOST_FILE, - DATABASE_USER: USER = "catapult", + // DATABASE_USER: USER = "catapult", DATABASE_USER_FILE: USER_FILE, - DATABASE_USER_PASSWORD: PASSWORD = "quartz", + // DATABASE_USER_PASSWORD: DB_PASSWORD, DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE, - DATABASE_NAME: DB = "catapult_player", + // DATABASE_NAME: DB = "catapult_player", DATABASE_NAME_FILE: DB_FILE, } = process.env; module.exports = async () => { - const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, - user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, - password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, - database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + // const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, + // user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, + // password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, + // database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST, + user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME, + password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD, + database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME; await waitPort({host, port: 3306}); diff --git a/player/.env.example b/player/.env.example index fa5d2fe..bb5460c 100644 --- a/player/.env.example +++ b/player/.env.example @@ -1,6 +1,11 @@ HOSTNAME=localhost HOST_PORT=63398 +DB_HOST=rdbms +DB_NAME=catapult_player +DB_USERNAME=catapult +DB_PASSWORD=quartz + CONTENT_URL=http://localhost:63398/content API_KEY="some API access key" diff --git a/player/docker-compose.yml b/player/docker-compose.yml index 63e6ad7..0002645 100644 --- a/player/docker-compose.yml +++ b/player/docker-compose.yml @@ -36,9 +36,13 @@ services: - LRS_USERNAME - LRS_PASSWORD - LRS_XAPI_VERSIONs - - DATABASE_USER=catapult - - DATABASE_USER_PASSWORD=quartz - - DATABASE_NAME=catapult_player + - DB_HOST + - DB_NAME + - DB_USERNAME + - DB_PASSWOD + # - DATABASE_USER=catapult + # - DATABASE_USER_PASSWORD=quartz + # - DATABASE_NAME=catapult_player - FIRST_TENANT_NAME - PLAYER_API_ROOT=${PLAYER_ROOT_PATH} - PLAYER_STANDALONE_LAUNCH_URL_BASE diff --git a/player/service/index.js b/player/service/index.js index b15d3d6..d7e8aea 100644 --- a/player/service/index.js +++ b/player/service/index.js @@ -65,7 +65,8 @@ const provision = async () => { } }; - await waitPort({host: "rdbms", port: 3306}); + const DB_HOST = (process.env.DB_HOST || "rdbms"); + await waitPort({host: DB_HOST, port: 3306}); const db = await require("./lib/db")(); diff --git a/player/service/knexfile.js b/player/service/knexfile.js index fee0df4..f112fa8 100644 --- a/player/service/knexfile.js +++ b/player/service/knexfile.js @@ -13,24 +13,35 @@ See the License for the specific language governing permissions and limitations under the License. */ + +const DB_HOST = (process.env.DB_HOST || "rdbms"); +const DB_NAME = (process.env.DB_NAME || "catapult_player"); +const DB_USERNAME = (process.env.DB_USERNAME || "catapult"); +const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz"); + const Hoek = require("@hapi/hoek"), waitPort = require("wait-port"), { - MYSQL_HOST: HOST = "rdbms", + // MYSQL_HOST: HOST = "rdbms", MYSQL_HOST_FILE: HOST_FILE, - DATABASE_USER: USER = "catapult", + // DATABASE_USER: USER = "catapult", DATABASE_USER_FILE: USER_FILE, - DATABASE_USER_PASSWORD: PASSWORD = "quartz", + // DATABASE_USER_PASSWORD: DB_PASSWORD, DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE, - DATABASE_NAME: DB = "catapult_player", + // DATABASE_NAME: DB = "catapult_player", DATABASE_NAME_FILE: DB_FILE, } = process.env; module.exports = async () => { - const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, - user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, - password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, - database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + // const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, + // user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, + // password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, + // database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST, + user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME, + password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD, + database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME; + await waitPort({host, port: 3306});