From 75d4e8a8c97733a51de071b126581c6193cd486f Mon Sep 17 00:00:00 2001 From: Raul Becker Date: Thu, 8 Feb 2018 05:10:39 +0200 Subject: [PATCH] build another test frontend container #4 this facebook worker thing is useless: https://github.com/facebook/create-react-app/issues/936 --- docker-compose.yml | 18 +++++++++++------- labtool2.0/src/registerServiceWorker.js | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3809b1db2..8d4295b36 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,19 +2,23 @@ version: '3' services: web: environment: - BACKEND_LOGIN_URL: "http://svm-61.cs.helsinki.fi/labtool-backend/" - image: labtool/labtool:dev + - BACKEND_LOGIN_URL=https://svm-61.cs.helsinki.fi/labtool-backend/ + - PUBLIC_HOST=svm-61.cs.helsinki.fi + - PUBLIC_PATH=/labtool + - PUBLIC_URL=https://svm-61.cs.helsinki.fi/labtool/... + image: labtool/labtool:test ports: - - "3000:3000" + - "6000:3000" depends_on: - backend + - db backend: environment: - TOKEN: "changeme" - NODE_ENV: "test" - image: labtool/labtool-backend:dev + - TOKEN=changeme + - NODE_ENV=test + image: labtool/labtool-backend:test ports: - - "3001:3001" + - "6001:3001" depends_on: - db db: diff --git a/labtool2.0/src/registerServiceWorker.js b/labtool2.0/src/registerServiceWorker.js index 4d2cb7877..73a7255d5 100644 --- a/labtool2.0/src/registerServiceWorker.js +++ b/labtool2.0/src/registerServiceWorker.js @@ -8,21 +8,20 @@ // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. // This link also includes instructions on opting out of this behavior. +/* TURHAA PASKAA const isLocalhost = Boolean( -if (!process.env.PUBLIC_URL && process.env.NODE_ENV !== 'development' && 'serviceWorker' in navigator) { window.location.hostname === 'localhost' || - -// [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' -// 127.0.0.1/8 is considered localhost for IPv4. -} else { + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. window.location.hostname.match( /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - }) + ) ) - +*/ export default function register() { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + if ((process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) + || (process.env.NODE_ENV === 'test' && 'serviceWorker' in navigator)) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { @@ -35,7 +34,8 @@ export default function register() { window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` - if (isLocalhost) { + // if (isLocalhost) { // KURA FACEBOOK COM + if (process.env.NODE_ENV === 'development') { // This is running on localhost. Lets check if a service worker still exists or not. checkValidServiceWorker(swUrl)