Creating the xos-nb-rest container

Change-Id: Id94bb31395d49e242bb67fcf79c0a5f731bab766
diff --git a/common/Makedefs b/common/Makedefs
index d20f493..c7a808d 100644
--- a/common/Makedefs
+++ b/common/Makedefs
@@ -10,6 +10,8 @@
 XOS_DIR              ?= $(HOME_DIR)/xos
 SERVICE_DIR          ?= $(HOME_DIR)/xos_services
 LIBRARY_DIR          ?= $(HOME_DIR)/xos_libraries
+REST_GW_DIR          ?= $(HOME_DIR)/xos-rest-gw
+GUI_DIR              ?= $(HOME_DIR)/xos-gui
 
 XOS_BOOTSTRAP_PORT   ?= 81
 XOS_UI_PORT          ?= 80
diff --git a/common/Makefile b/common/Makefile
index 48f5ef3..4451670 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -173,6 +173,14 @@
 xos_test_c:
 	cd $(XOS_DIR)/containers/xos; make test
 
+xos_rest_gw_c:
+	# this folder is cloned by repo
+	cd $(REST_GW_DIR); docker build -t xosproject/xos-rest-gw .
+
+xos_gui_c:
+	# this folder is cloned by repo
+	cd $(GUI_DIR); docker build -t xosproject/xos-gui .
+
 
 # utilties/convenience targets
 cleanup: stop rm $(CONFIG_DIR)/cleanup.sh
diff --git a/frontend/Makefile b/frontend/Makefile
index 47d8349..9ced6ef 100644
--- a/frontend/Makefile
+++ b/frontend/Makefile
@@ -111,3 +111,10 @@
 	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 rm -f /opt/xos/xos_configuration/xos_mcord_config
 	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 rm -f /opt/xos/xos_configuration/xos_cord_config
 
+experimental-ui: xos_rest_gw_c xos_gui_c
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/ui_containers.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
+	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
+	bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
+
diff --git a/frontend/Vagrantfile b/frontend/Vagrantfile
index b67c7fa..551e949 100644
--- a/frontend/Vagrantfile
+++ b/frontend/Vagrantfile
@@ -3,10 +3,7 @@
   config.vm.box = "ubuntu/trusty64"
 
   # share the folder
-  config.vm.synced_folder "../", "/home/vagrant/service-profile"
-  config.vm.synced_folder "../../xos", "/home/vagrant/xos", create: true
-  config.vm.synced_folder "../../xos_services", "/home/vagrant/xos_services", create: true
-  config.vm.synced_folder "../../xos_libraries", "/home/vagrant/xos_libraries", create: true
+  config.vm.synced_folder "../../", "/home/vagrant/", create: true
   config.vm.synced_folder ".", "/vagrant", disabled: true
 
   # set the frontend vm
diff --git a/frontend/docker-compose-bootstrap.yml b/frontend/docker-compose-bootstrap.yml
index a2aadd2..db50669 100644
--- a/frontend/docker-compose-bootstrap.yml
+++ b/frontend/docker-compose-bootstrap.yml
@@ -2,6 +2,8 @@
     image: xosproject/xos-postgres
     expose:
         - "5432"
+    ports:
+        - "5432:5432"
 
 xos_redis:
     image: redis
diff --git a/frontend/gateway-config.yml b/frontend/gateway-config.yml
new file mode 100644
index 0000000..ae1f0b1
--- /dev/null
+++ b/frontend/gateway-config.yml
@@ -0,0 +1,9 @@
+default:
+  xos:
+    host: xos
+    port: 9999
+  redis:
+    host: redis
+    port: 6379
+  gateway:
+    port: 3000
\ No newline at end of file
diff --git a/frontend/ui_containers.yaml b/frontend/ui_containers.yaml
new file mode 100644
index 0000000..932831e
--- /dev/null
+++ b/frontend/ui_containers.yaml
@@ -0,0 +1,69 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    # API Gateway
+    xos-rest-gateway:
+      type: tosca.nodes.Component
+      properties:
+        name: xos-rest-gateway
+        image: xosproject/xos-rest-gw
+        command: npm start -- --config gateway-config.yml
+        ports: 3000:3000
+
+    /var/www/src/config/gateway-config.yml:
+      type: tosca.nodes.ComponentVolume
+      properties:
+          host_path: { path_join: [ SELF, CONFIG_DIR, ./gateway-config.yml, ENV_VAR ] }
+          read_only: false
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.VolumeOfComponent
+
+    gw-to-xos:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: xos_ui
+          alias: xos
+          kind: internal
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.LinkOfComponent
+
+    gw-to-redis:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: frontendbs_xos_redis_1
+          alias: redis
+          kind: external
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.LinkOfComponent
+
+    # UI Container
+    xos-spa-gui:
+      type: tosca.nodes.Component
+      properties:
+        name: xos-spa-gui
+        image: xosproject/xos-gui
+        ports: 80:80
+
+    gui-to-gw:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: xos-rest-gateway
+          alias: xos-rest-gw
+          kind: internal
+      requirements:
+          - xos:
+             node: xos-spa-gui
+             relationship: tosca.relationships.LinkOfComponent
\ No newline at end of file