This how-to will focus on deploying to Pivotal Web Services.
This how-to will teach you how to do the following:
- Configure Pivotal and the Pivotal environment
- Add services to the app
- Deploy your app to Cloud Foundry
Before starting this how-to, make sure you have completed the following prerequisites:
- Download the latest version of the Mendix Modeler from the Mendix App Store
- Have access to a Pivotal Web Services account with the rights to create new applications and services (if you’re not a current Pivotal customer, you can sign up for a free 60-day trial)
- Have an S3 or S3-compatible object store with user credentials, a bucket, and rights to create and delete objects
To push a Mendix app to Cloud Foundry, you have to configure the settings in the Modeler.
To configure Pivotal in the Modeler, follow these steps:
Open the Modeler, click Run, and select Edit Pivotal Settings:
In the credentials section of the Edit Pivotal Settings configuration window, do the following:
- Enter https://api.run.pivotal.io/ for the API endpoint
- Enter your Pivotal WS username for the User name
- Enter your Pivotal WS password for the Password
Click Next. You will be logged into your Pivotal instance.
Enter the following details:
- Select the organization you want to use (for example, mendix-rnd.com) for Organization
- Select the space you want to deploy your app to (for example, new-buildpack-testing) for Space
- Select Create new app
- Enter a name for your new app (for example, CompanyExpenses) for App name
Click Next. The app will be created in the Pivotal WS environment.
In the final section of the the Edit Pivotal Settings configuration window, do NOT click Finish until you have completed the configuration steps in the following sections:
- 4 Configure the Pivotal Environment
- 5 Add a Database Service to Your App
- 6 Add a FileStore Service to Your App
To configure the Pivotal environment, go to http://console.run.pivotal.io and log in with your Pivotal WS credentials:
After logging in, you will see the Pivotal home screen. The following details on this screen are important:
- You can see that you are logged in at the top-right of the screen
- In the sidebar on the left side of the screen, you can see the organization you have access to and the spaces within that organization
- In the center of the screen, you can see the spaces, domains, and other users who are a member of this organization.
Apps make use of services (for example, databases, load balancers, and memory tools). In this step, you will add a database service that your app will use to store data.
To add a database service to your app, follow these steps:
Click the space where you created your app:
The app you created is there, but it isn’t running yet. This is because it doesn’t have any services attached to it yet.
Click Add Service:
This is a PostgreSQL database that your app will use. Mendix supports PostgreSQL and MySQL databases on Cloud Foundry. For some database services that do not add a
DATABASE_URLenvironment variable, you will need to set that manually.
Select the plan that fits your needs. This example will use the free option:
In the CONFIGURE INSTANCE section of the screen, do the following:
- Enter the name of the ElephantSQL database (for example, ComanyExpensesDataStore) for Instance Name
- Select the space you want to add the instance to for Add to Space
- Select the app you want to bind the database instance to (for example, CompanyExpenses) for Bind to App
Click Add to finish the service configuration for ElephantSQL:
The app you bound the service to will be loaded.
Scroll down to see the services bound to the app:
To enable persistent file storage, you need to configure the S3 object store (which was introduced in Mendix 5.15). Mendix supports S3 and the object stores that enable the S3 API. To make sure the FileDocuments in your application persist, you need to set up the following environment variables:
|S3_ACCESS_KEY_ID||The access key of your IAM credentials.||AKIAILYXS5VM4DQ7CTWQ||Yes|
|S3_SECRET_ACCESS_KEY||The secret key of your IAM credentials.||XfSrHqbLG3D8VIPhn1vT7jN9H8w4ak3GAap/xcR1||Yes|
|S3_BUCKET_NAME||The bucket name that can be accessed using the IAM credentials above.||my-s3-bucket||Yes|
|S3_ENDPOINT||Not needed if you are using Amazon S3. If you are using an S3-compatible object store (such as Riak CS and Ceph), you can use the domain name of the object store.||s3.amazonaws.com||No|
|S3_KEY_SUFFIX||For multi-tenant buckets, you can add a suffix to each object name. Access to suffixed objects can be restricted using IAM policies.||-my-key-suffix||No|
|S3_PERFORM_DELETES||Set to false when using the object store in append-only mode. In this mode, the backups can be created and restored via just the database.||false||No|
|S3_USE_V2_AUTH||Set to true to force the S3 connector to use V2 of the AWS authentication protocol. This is required for S3-compatible file stores that do not support V4 of the authentication protocol (such as Riak CS, Ceph, and OpenStack Swift).||true||No|
- Go to the Pivotal Web Services environment.
Open your app from the top menu:
Go to the Environment Variables tab:
Add the required S3 variables:
Add any optional variables:
When adding environment variables to a running application, you need to restart it for the changes to take effect.
After deploying an app from the Modeler, two variables will be added automatically:
ADMIN_PASSWORD. The development mode is true by befault; change this to false to run the app in production. The admin password is the password of the default admin of your Mendix app.
7 Deploy Your App to Cloud Foundry
- Open the Modeler
- Open the app you want to deploy to Cloud Foundry.
Click the arrow for the Run options and select Run on Cloud Foundry:
The Mendix app will now be deployed to the configured Pivotal app and started automatically
If you encounter any problems, you should consult the application logs:
- Go to the Pivotal web services environment.
Open your app from the top menu:
Go to the Logs tab:
View the most recent log lines:
To view new log lines while they come in, click Tail Logs on the right:
You can now see log lines appear in real time: