diff --git a/Jenkinsfile b/Jenkinsfile index eb9ac1c939e99c9f4cab56b3c59a662fcaa7e8c0..aea7cbe1bf13c0fb18df835644ba25c26f29b900 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,9 +36,10 @@ pipeline { def targetS3Url = env.TARGET_S3_URL def smokeURL = env.SMOKE_URL def janusServer = env.JANUS_SERVER + def reticulumServer = env.RETICULUM_SERVER def slackURL = env.SLACK_URL - def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer} ${janusServer} ${targetS3Url} ${env.BUILD_NUMBER} ${env.GIT_COMMIT}" + def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer} ${janusServer} ${reticulumServer} ${targetS3Url} ${env.BUILD_NUMBER} ${env.GIT_COMMIT}" sh "/usr/bin/script --return -c ${shellString(habCommand)} /dev/null" def gitMessage = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'[%an] %s'").trim() diff --git a/scripts/default.env b/scripts/default.env index 0608178224ff91d4a5877e6b53e8fcf8bdca27fb..bf0095e05da1ad223661fc0fc8de1985f0756d76 100644 --- a/scripts/default.env +++ b/scripts/default.env @@ -3,5 +3,5 @@ ORIGIN_TRIAL_TOKEN="AmTuFlYFGJ4KEbPVE20U0qoWZI3NZuaO8bjjcQvQI4OvDVC4Iyun5gkD8lwtNbrEzh617m5nig0+8QC+Pz6powYAAABVeyJvcmlnaW4iOiJodHRwczovL2h1YnMubW96aWxsYS5jb206NDQzIiwiZmVhdHVyZSI6IldlYlZSMS4xTTYyIiwiZXhwaXJ5IjoxNTM0ODg3ODE1fQ==" ORIGIN_TRIAL_EXPIRES="2018-08-21" JANUS_SERVER="wss://dev-janus.reticulum.io" -DEV_RETICULUM_SERVER="dev.reticulum.io" +RETICULUM_SERVER="dev.reticulum.io" ASSET_BUNDLE_SERVER="https://asset-bundles-prod.reticulum.io" diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh index 0318151268f153568168c90fcd9b069b4ab68919..bfe60faff8d3a59811fb0e9db07211f9b12433e8 100755 --- a/scripts/hab-build-and-push.sh +++ b/scripts/hab-build-and-push.sh @@ -3,9 +3,10 @@ export BASE_ASSETS_PATH=$1 export ASSET_BUNDLE_SERVER=$2 export JANUS_SERVER=$3 -export TARGET_S3_URL=$4 -export BUILD_NUMBER=$5 -export GIT_COMMIT=$6 +export RETICULUM_SERVER=$4 +export TARGET_S3_URL=$5 +export BUILD_NUMBER=$6 +export GIT_COMMIT=$7 export BUILD_VERSION="${BUILD_NUMBER} (${GIT_COMMIT})" # To build + push to S3 run: diff --git a/scripts/run-local-reticulum.sh b/scripts/run-local-reticulum.sh index 0c08a28609c7ddafb579e58171264f64d4e7dffc..a9dc185616db86da9ffcba218130e29b13c3e7a7 100755 --- a/scripts/run-local-reticulum.sh +++ b/scripts/run-local-reticulum.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -BASE_ASSETS_PATH=https://hubs.local:8080/ DEV_RETICULUM_SERVER=hubs.local:4000 npm start +BASE_ASSETS_PATH=https://hubs.local:8080/ RETICULUM_SERVER=hubs.local:4000 npm start diff --git a/src/react-components/hub-create-panel.js b/src/react-components/hub-create-panel.js index 4fb1a9f4335cd7fd7dac40ae196535b614bf773c..30c452e3669472d67a15b8e1704fcef2cef8ab2e 100644 --- a/src/react-components/hub-create-panel.js +++ b/src/react-components/hub-create-panel.js @@ -87,8 +87,8 @@ class HubCreatePanel extends Component { let createUrl = "/api/v1/hubs"; - if (process.env.NODE_ENV === "development") { - createUrl = `https://${process.env.DEV_RETICULUM_SERVER}${createUrl}`; + if (process.env.RETICULUM_SERVER) { + createUrl = `https://${process.env.RETICULUM_SERVER}${createUrl}`; } const res = await fetch(createUrl, { @@ -99,7 +99,7 @@ class HubCreatePanel extends Component { const hub = await res.json(); - if (process.env.NODE_ENV === "production" || document.location.host === process.env.DEV_RETICULUM_SERVER) { + if (document.location.host === process.env.RETICULUM_SERVER) { document.location = hub.url; } else { document.location = `/hub.html?hub_id=${hub.hub_id}`; diff --git a/src/utils/media-utils.js b/src/utils/media-utils.js index e864bfc9fd979ef42b4fd4083cd67325e3465b3a..96e3b618a79a0f492cd64d9f82d551aace83f795 100644 --- a/src/utils/media-utils.js +++ b/src/utils/media-utils.js @@ -1,8 +1,9 @@ const whitelistedHosts = [/^.*\.reticulum\.io$/, /^.*hubs\.mozilla\.com$/, /^hubs\.local$/]; const isHostWhitelisted = hostname => !!whitelistedHosts.filter(r => r.test(hostname)).length; let mediaAPIEndpoint = "/api/v1/media"; -if (process.env.NODE_ENV === "development") { - mediaAPIEndpoint = `https://${process.env.DEV_RETICULUM_SERVER}${mediaAPIEndpoint}`; + +if (process.env.RETICULUM_SERVER) { + mediaAPIEndpoint = `https://${process.env.RETICULUM_SERVER}${mediaAPIEndpoint}`; } const resolveMediaCache = new Map(); diff --git a/src/utils/phoenix-utils.js b/src/utils/phoenix-utils.js index 91317a70d4ea0563842954ef407631c64a1ecacc..b1b1e129ac1926b776b9b632f0626a14e3b22ff7 100644 --- a/src/utils/phoenix-utils.js +++ b/src/utils/phoenix-utils.js @@ -5,10 +5,18 @@ export function connectToReticulum() { const qs = new URLSearchParams(location.search); const socketProtocol = qs.get("phx_protocol") || (document.location.protocol === "https:" ? "wss:" : "ws:"); - const [retHost, retPort] = (process.env.DEV_RETICULUM_SERVER || "").split(":"); - const isProd = process.env.NODE_ENV === "production"; - const socketPort = qs.get("phx_port") || (isProd ? document.location.port : retPort) || "443"; - const socketHost = qs.get("phx_host") || (isProd ? document.location.hostname : retHost) || ""; + let socketHost = qs.get("phx_host"); + let socketPort = qs.get("phx_port"); + + if (process.env.RETICULUM_SERVER) { + const [retHost, retPort] = process.env.RETICULUM_SERVER.split(":"); + socketHost = socketHost || retHost || ""; + socketPort = socketPort || retPort || "443"; + } else { + socketHost = socketHost || document.location.hostname || ""; + socketPort = socketPort || document.location.port || "443"; + } + const socketUrl = `${socketProtocol}//${socketHost}${socketPort ? `:${socketPort}` : ""}/socket`; console.log(`Phoenix Socket URL: ${socketUrl}`); diff --git a/webpack.config.js b/webpack.config.js index 07dcf72f66e6d9a1165b693a602a5cc4c18aac04..ddbec2c9be50b3ccf9849d2424b0ecdcde4bd679 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -244,7 +244,7 @@ module.exports = (env, argv) => ({ "process.env": JSON.stringify({ NODE_ENV: argv.mode, JANUS_SERVER: process.env.JANUS_SERVER, - DEV_RETICULUM_SERVER: process.env.DEV_RETICULUM_SERVER, + RETICULUM_SERVER: process.env.RETICULUM_SERVER, ASSET_BUNDLE_SERVER: process.env.ASSET_BUNDLE_SERVER, BUILD_VERSION: process.env.BUILD_VERSION })