---
applications:

###
### "Task" applications to setup services, see https://docs.cloudfoundry.org/devguide/using-tasks.html
###

- name: mongo-init
  path: ../CF/mongo-init
  memory: 128M
  no-route: true # It's a CF Task, does not need a route
  health-check-type: process
  instances: 0

- name: mysql-init
  path: ../CF/mysql-init
  memory: 512M
  no-route: true # It's a CF Task, does not need a route
  health-check-type: process
  instances: 0

###
### Productive apps
###

- name: cart
  path: ../cart/
  memory: 128M
  env:
    CATALOGUE_HTTPS: true
  instances: 0

- name: catalogue
  path: ../catalogue/
  instances: 0

- name: dispatch
  path: ../dispatch/src
  memory: 128M
  health-check-type: process
  env:
    GOPACKAGENAME: github.com/instana/robot-shop/dispatch
  instances: 0

- name: payment
  path: ../payment/
  memory: 256M
  env:
    AUTOWRAPT_BOOTSTRAP: instana
  instances: 0

- name: ratings
  path: ../ratings/app
  memory: 128MB
  env:
    CATALOGUE_USE_HTTPS: true
  instances: 0

- name: shipping
  path: ../shipping/target/shipping-1.0-jar-with-dependencies.jar
  memory: 1G
  instances: 0

- name: user
  path: ../user/
  memory: 128MB
  instances: 0

- name: web
  path: ../web/
  memory: 128M
  buildpacks:
    - https://github.com/mmanciop/nginx-buildpack.git#nginx-1.17.2
  instances: 0

- name: loadgeneration
  path: ../load-gen
  buildpacks:
    - https://github.com/cloudfoundry/python-buildpack.git#v1.6.36
  no-route: true
  health-check-type: process
  memory: 1GB
  env:
    HOST: http://web.apps.pcf264.qainfra.instana.io
    CLIENTS: 5
  instances: 5

# cf cs p.mysql db-small mysql-cities
# cf cs p.mysql db-small mysql-ratings
# cf cs mongodb-odb replica_set_small mongodb
# cf cs p.redis cache-small redis
# cf cs p.rabbitmq single-node-3.7 rabbitmq

# cf bind-service mongo-init mongodb --binding-name catalogue_database
# cf run-task mongo-init 'node init-db.js' --name "Init MongoDB"

# cf bind-service mysql-init mysql-ratings --binding-name ratings_database
# cf run-task mysql-init 'node init-db.js init-ratings.sql ratings_database' --name "Init Ratings database"

###
### DOES NOT WORK DUE TO THE SIZE OF THE DATABASE TO BE IMPORTED
### MUST IMPORT DATA MANUALLY:
### 1) BOSH SSH into the MySQL VM
### 2) Find out admin password from /var/vcap/jobs/mysql/config/mylogin.cnf
### 3) Download init sql from https://github.com/mmanciop/robot-shop/raw/master/mysql/scripts/10-dump.sql.gz and gunzip it
### 4) /var/vcap/packages/percona-server/bin/mysql -u admin -p<adminpwd> -P 3306 -D service_instance_db < init.sql 
# cf bind-service mysql-init mysql-ratings --binding-name shipping_database
# cf run-task mysql-init 'node init-db.js init-cities.sql shipping_database' --name "Init Shipping database"

# cf bind-service ratings mysql-ratings --binding-name ratings_database
# cf scale -i 1 ratings
# cf restage ratings

# cf bind-service catalogue mongodb --binding-name catalogue_database
# cf scale -i 1 catalogue
# cf restage catalogue

# cf bind-service cart redis --binding-name cart_cache
# cf scale -i 1 cart
# cf restage cart

# cf bind-service shipping mysql --binding-name shipping_database
# cf scale -i 1 shipping
# cf restage shipping

# cf bind-service user redis --binding-name users_cache
# cf bind-service user mongodb --binding-name users_database
# cf scale -i 1 user
# cf restage user

# cf bind-service payment rabbitmq --binding-name dispatch_queue
# cf scale -i 1 payment
# cf restage payment

# cf bind-service dispatch rabbitmq --binding-name dispatch_queue
# cf scale -i 1 dispatch
# cf restage dispatch

# cf scale -i 1 web