user1621204
user1621204

Reputation: 1

Grails App with Multi Tenant Single DB plugin URL implementation in Cloudfoundry

I am currently creating a web app using Grails implementing Multi Tenant Single DB plugin. The plugin allows me to have multiple tenants on a single db using a tenantID to differentiate between tenants. The plugin detects witch tenant will deal the current request that is made on my app by resolving using different domains/subdomains for each tenant.

For example:

On my local machine running Grails development mode I was able to implement the different hosts by changing my /etc/hosts and each tenant would have their own subdomain.

I am currently interested in using cloud foundry as my cloud platform but when I deploy my app to cloud foundry it is already using my app name as the subdomain for cloud foundry.

For example: - myapp.cloudfoundry.com

  1. Is it possible to change or control the domain name resolver in cloud foundry?
  2. Does anybody know how to handle multi-tenant subdomains as explained above in cloud foundry? Probably provide the steps in implementing this using cloud foundry?
  3. What is the best approach to implement this using cloud foundry?

My App is using Grails 2.0.4 and Multi Tenant Single DB plugin 0.8.2.

Thanks

Upvotes: 0

Views: 645

Answers (1)

William Gu
William Gu

Reputation: 852

Unfortunately the current beta version CloudFoundry does not allow modification of the cloudfoundry subdomain. The plan is to have the GA towards the end of this year with a private preview of the version of the site available sooner in the fall. At that time you could be able to customize the subdomain. Therefore you might need to change a little in your TenantResolver to only check the subdomain that varies.

To implement your requirement, did you try installing the grails cf plugin? If not you can start from here.

If you are using cli, installing the plugin just needs command in your project workspace:

grails install-plugin cloud-foundry

When your app is ready for deployment, push it to cloudfoundry:

grails cf-push

Note that you will have to have your cf credentials configured in the grails config file. After that you can map multiple URLs you want using:

grails cf-map user1.yourapp.cloudfoundry.com

If you have already known about vmc which is the client command line interface for cf, you can see the urls mapped with your app by

vmc apps

If not you can refer to the installation guide to start if you would like to do that.

If you are using STS/eclipse, things will be even easier. First you need to have grails-support extension as well as the cloud foundry integration installed. For detailed docs of the cf integration please refer here.

After your app is deployed, right click the project and choose "Grails Tools" -> "Open Grails Command Prompt". This will enable you to have same grails cf plugin commands as the CLI does.

Hope this can help your move forward in the cloudfoundry world. Let me know if you have more questions.

Thanks, William

Upvotes: 1

Related Questions