Merge "Moved SPA to port 4000 #CORD-712"
diff --git a/Dockerfile b/Dockerfile
index 8dd7ce4..1e33e62 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,11 +19,14 @@
 # Add the app
 COPY ${CODE_SOURCE} ${CODE_DEST}
 
-# Build the app
+# Install Deps
 WORKDIR ${CODE_DEST}
 RUN npm install 
-RUN npm run build
 
 # Override nginx configutaion
+RUN mkdir -p /var/log/nginx/log
 RUN mv ${CODE_SOURCE}/nginx.conf /etc/nginx/conf.d/default.conf
-#RUN service nginx restart
\ No newline at end of file
+
+# Build the app
+EXPOSE 4000
+RUN npm run build
\ No newline at end of file
diff --git a/conf/app/app.config.production.ts b/conf/app/app.config.production.ts
index c6e774c..b1a1b7d 100644
--- a/conf/app/app.config.production.ts
+++ b/conf/app/app.config.production.ts
@@ -1,5 +1,5 @@
 import {IAppConfig} from './interfaces';
 export const AppConfig: IAppConfig = {
-    apiEndpoint: '/api',
-    websocketClient: ''
+    apiEndpoint: '/spa/api',
+    websocketClient: '/spa'
 };
diff --git a/conf/webpack-dist.conf.js b/conf/webpack-dist.conf.js
index 1ee1855..9e0f3c9 100644
--- a/conf/webpack-dist.conf.js
+++ b/conf/webpack-dist.conf.js
@@ -61,6 +61,7 @@
   postcss: () => [autoprefixer],
   output: {
     path: path.join(process.cwd(), conf.paths.dist),
+    publicPath: "/spa/", // enable apache proxying on the head node
     filename: '[name]-[hash].js'
   },
   resolve: {
diff --git a/nginx.conf b/nginx.conf
index cca72d5..6150ae8 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -1,21 +1,28 @@
 server {
-    listen       81;
+    listen       4000;
     server_name  localhost;
 
     #charset koi8-r;
-    #access_log  /var/log/nginx/log/host.access.log  main;
+    access_log  /var/log/nginx/log/xos-spa-gui.access.log  main;
+    error_log  /var/log/nginx/log/xos-spa-gui.error.log  warn;
 
     location / {
         root   /var/www/dist;
         index  index.html index.htm;
     }
 
-    location /api {
+    # Redirect for FE config
+    location /spa {
+        root   /var/www/dist;
+        index  index.html index.htm;
+    }
+
+    location /spa/api {
         resolver 127.0.0.1 valid=30s;
         proxy_pass http://xos-rest-gw:3000;
     }
 
-    location /socket.io {
+    location /spa/socket.io {
         resolver 127.0.0.1 valid=30s;
         proxy_pass http://xos-rest-gw:3000;
     }
diff --git a/package.json b/package.json
index 6b5ab55..955c539 100644
--- a/package.json
+++ b/package.json
@@ -78,8 +78,10 @@
     "webpack": "2.1.0-beta.20"
   },
   "scripts": {
+    "postinstall": "npm run typings",
     "build": "gulp",
     "start": "gulp serve",
+    "typings": "typings install",
     "serve:dist": "gulp serve:dist",
     "pretest": "npm run lint",
     "test": "gulp test",
diff --git a/src/index.ts b/src/index.ts
index c23c075..e925e08 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -85,6 +85,7 @@
     // save the last visited state before reload
     const lastRoute = window.location.hash.replace('#', '');
 
+    // TODO this must be triggered only when user is authenticated
     // Dinamically add a  core states
     ModelDefs.get()
       .then((models: IModeldef[]) => {
diff --git a/typings.json b/typings.json
index ae78607..a830275 100644
--- a/typings.json
+++ b/typings.json
@@ -11,5 +11,8 @@
     "jquery": "registry:dt/jquery#1.10.0+20161119044246",
     "require": "registry:dt/require#2.1.20+20160316155526",
     "socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654"
+  },
+  "dependencies": {
+    "angular-toastr": "registry:dt/angular-toastr#1.6.0+20160708003927"
   }
 }