This how-to will focus on deploying to Pivotal Web Services. Note that the outline is the same for all Cloud Foundry distributions.

To follow this guide you will need to have access to a Pivotal Web Services account with the rights to create new applications and services. You should also have an S3 or S3 compatible object store with user credentials, a bucket and rights to create and delete objects.

1. Preparation

2. Configure Cloud Foundry in the Modeler

To push a Mendix app to Cloud Foundry you will have to configure the settings in the Mendix Modeler.

  1. Open the Mendix Modeler.
  2. Go to Run > Edit Pivotal Settings:
  3. Enter the following details in the settings window:

    Cloud Foundry CredentialsValue
    Urlhttps://api.run.pivotal.io
    User nameYour Pivotal WS user name
    PasswordYour Pivotal WS password

  4. Click Next. You will be logged into your Pivotal Instance.

  5. Enter the following details:

    AppValue
    OrganizationSelect the organization you want to use (i.e. mendix.com).
    SpaceSelect the space you want to deploy your app to (i.e. staging).
    AppSelect Create new app
    App nameEnter a name for your new app (i.e. CompanyExpenses).

  6. Click Next. The App will be created in the Pivotal WS environment.

    Do not click Finish until you have completed the configuration steps for the Database and FileStore services below.

3. Configure the Pivotal Environment

  1. 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:

  • You can see that you are logged in at the top right of the screen.
  • In the sidebar on the left 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.

4. Add a Database Service to an App

Apps make use of services. Think of Databases, Load Balancers, and Memory tools. In this step you will add a Database service that your app will use to store data.

  1. Click on the Space where you created your App: The app you created is there but isn’t running yet, because it doesn’t have any services attached to it yet.

  2. Click on Add Service.
  3. Select ElephantSQL: 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_URL environment variable you will need to set that manually.

  4. Select a plan that fits your needs. This example will use the free option.
  5. Enter  the following details:

    AppValue
    Instance NameEnter the name of the ElephantSQL Database, i.e. ComanyExpensesDataStore.
    Add to SpaceSelect the space you want to add the instance to.
    Bind to AppSelect the App you want to bind the database Instance to, i.e. CompanyExpenses.

  6. Click Add to finish the service configuration for ElephantSQL.   The App you bound the Service to will be loaded.

  7. Scroll down to see the Services bound to the App.

5. Add a FileStore Service to you App

To enable persistent file storage you need to configure the S3 object store which was introduced in Mendix 5.15. Mendix support S3 and 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.

VariableValueRequired
S3_ACCESS_KEY_ID

Access Key of your IAM credentials

Example: AKIAILYXS5VM4DQ7CTWQ

Yes
S3_SECRET_ACCESS_KEY

Secret Key of your IAM credentials

Example: XfSrHqbLG3D8VIPhn1vT7jN9H8w4ak3GAap/xcR1

Yes
S3_BUCKET_NAME

The bucket name which can be accessed using the IAM credentials above

Example: 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, Ceph etc. you can use the domain name of the Object Store.

Example: 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.

Example: -my-key-suffix

No
S3_PERFORM_DELETES

Set to 'false' when using the Object Store in append-only mode. In this mode backups can be created and restored via just the database.

Example: 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, OpenStack Swift etc.

Example: true

No
  1. Go to the Pivotal Web Services environment.
  2. Open your App from the top menu:
  3. Go to the Environment Variables tab.
  4. Add the required S3 variables:
  5. 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 Mendix Modeler two variables will automatically be added: DEVELOPEMENT_MODE and 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.

6. Deploy your App to Cloud Foundry

  1. Open the Mendix Modeler.
  2. Open the App you want to deploy to Cloud Foundry.
  3. 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

7. Troubleshooting

If you encounter any problems you should consult the application logs.

  1. Go to the Pivotal Web Services environment.
  2. Open your App from the top menu:
  3. Go to the Logs tab.
  4. View to the most recent log lines:
  5. To view new log lines while they come in, use the Tail Logs button on the right:
  6. You can now see log lines appear in real time: