Getting started with Mendix Web App on IBM Cloud
Mendix starter app on IBM Cloud gives you a head start developing a fully-featured web application using the Mendix low-code platform. The app is ready for you to add data structures, pages, and application logic using the visual development environment in Mendix. The app comes with a default theme that you can customize to deliver beautiful, and innovative apps that run on any device.
This how-to will teach you how to do the following:
- Select an IBM app template and ask Mendix to create the app
- Create a deployment package for IBM Cloud
- Deploy to, and test your app on, IBM Cloud
Prerequisites
Before starting this how-to, make sure you have completed the following prerequisites:
- Have an IBM Cloud account
- Download the Mendix Desktop Modeler – you will need 7.11.0 or higher
- Be familiar with the basic concepts of editing and deploying a Mendix app
- Be familiar with the basic concepts of IBM Starter Kits and Toolchain
Creating the New App
Firstly, you create your Mendix app which you wish to deploy.
- Log in to your Mendix Account.
- Click Create App to create a new app.
- Click an IBM app to choose it as the starting point for your app.
- Click Use this app.
- Choose a name for your app and click Create App.
- Wait while Mendix creates a copy of the starter app you have chosen and takes you to a page from which you can set up IBM Cloud.
Setting Up the Project on IBM Cloud
Mendix knows you want to deploy to IBM Cloud, but you need tell it more about your project so that IBM Cloud can add the resources you need.
To set up IBM Cloud, follow these steps:
- Click Setup Cloud.
- Log in to IBM Cloud if you are not already logged in.The App name name of your project is already filled in. It is recommended that you do not change this; changing this name will not change the name of your app in the Mendix Developer Portal.
- Ensure that the correct account is shown at the top right of the screen (next to your avatar) if you have access to more than one account on IBM Cloud.
- Choose the appropriate Resource Group.
- Click Create.
- Click Link Account.
This is only required for new projects. It links this project to the project on Mendix.
If you have not linked an IBM Cloud project to Mendix before, you will be asked to confirm that IBM Cloud can have access to some of your Mendix data. Please Authorize this.
You will now be returned to the project page.
Deploying to Cloud Foundry
- Set the Number of instances; the default is 1.
- Set the Memory allocation per instance; the default is 512.
- Choose the Region, Organization, Space, and Domain to deploy to.
- Change the Host if required; the default is the name of your app.
It is possible that your deployment will fail if your Host is not unique within your region. If this occurs, use a different host name.
- Click Create.
- Wait until the Deployment Details indicate that the toolchain is configured.
Deploying to Kubernetes
Please note that the default setup for deploying to Kubernetes to IBM Cloud is not currently suitable for production environments. Please refer to IBM documentation or contact Mendix support if you want to use Kubernetes for a production environment on IBM Cloud.
- Choose the Region, Organization, Space, and Cluster name to deploy to.
- Click Create.
- Wait until the Deployment Details indicate that the toolchain is configured.
Creating a Package for IBM Cloud
Before you can deploy a package to IBM Cloud you have to create it. At any time, you can create a new deployment package from a committed version of the project. If you are working with the Desktop Modeler you will have to commit the project first.
Deploying from Within the Desktop Modeler
You can deploy your app automatically from the Desktop Modeler. However, you will have less control over the deployment than deploying from the Developer Portal.
Click Run in the Desktop Modeler. This will automatically:
- commit the project
- generate a deployment package from the latest commit in the current branch
- push the deployment package to IBM Cloud
You will still need to go to IBM Cloud and manually deploy the package; a message within the Desktop Modeler will let you know when the package is ready and will give you the link to IBM Cloud.
Deploying from the Developer Portal
To create a package for IBM Cloud within Developer Portal, follow these steps:
- Return to the Mendix Developer Portal. If you are looking at your app on IBM Cloud you can click Edit on Mendix to return to Mendix.
- Open the Environments page.You are now ready to create a deployment package which you will then push to IBM Cloud.
- Click Create package from teamserver.
- Select the branch on which to base the build and click Next.
Initially, you will only have the Main line. However, when you create deployment packages in the future, there may be other branches available.
- Select the revision of this branch and click Next.
You will see a number if revisions. Note that a package cannot be created from the first revision as this contains no application template.
Please do not choose to create a package from revision number 1.
- Type a Tag description (optional) and set the version number for this build.
- Click Build this revision.
- Click OK to confirm the information message.
- Click Details next to the deployment package to see details of the deployment package.You can now see and manipulate the package details.
- Click Environments to return to the previous page.When the project is built it will appear in the list of deployment packages. While it is being built, there will be a ‘spinner’ showing that the package is not yet complete. Once the package is ready for deployment this will be replaced by a tick.
The package is still within the Mendix environment and needs to be pushed to IBM Cloud. From there it can be deployed.
- Click Push next to the package you want to deploy. This will push this deployment package to IBM Cloud.
Deploying a Package to IBM Cloud
A package is sent to IBM Cloud to be deployed. Currently you have to do this deployment manually.
- Click the here link or the Open IBM Cloud button to go to your IBM Cloud project page.Alternatively, follow the link you are given in the Desktop Modeler.
You may need to configure your browser to allow the IBM Cloud page to open.
You will now be back on your IBM Cloud project page.
- Click Deploy Application.You will see a confirmation message in the top right of the screen.
- Wait until the app is deployed. This can take several minutes.If you want to see the progress then do the following:
- Click View toolchain
- Click the DELIVER > Delivery Pipeline tool in the toolchain
- The Deploy Stage will indicate STAGE PASSED when your app has been deployed (if you are encountering issues, you can click the link on this page to see the build log)
Although there is a button here marked View app, it is not currently possible to see your app this way. You will need to view it from the Mendix site.
Under some circumstances, the toolchain for Kubernetes cannot be built.
Go to the toolchain and look at the log from the Build Stage. If the log includes the message
You have exceeded your storage quota. Delete one or more images, or review your storage quota and pricing plan.
, then you will need to remove any images by going to Containers > Registry > Images and deleting them.You can also see when your deployment is complete from the Mendix app’s Environments page.
- Click Edit on Mendix to return to Mendix.
- Click Environments to see the Mendix environments page.When the deployment is complete you will see your deployed app under Managed by IBM Cloud. You will also see activities related to the deployment under Activity.
- Click View App to run and view your app.You can also view your app directly using the url which is given to you:
Runtime Configuration
Once your app is deployed, you can make changes to the runtime on IBM Cloud.
To change your runtime configuration, perform the following steps:
- Go to IBM Cloud by clicking the Details button next to your environment, or using the Open IBM Cloud button.
- Click Dashboard above the name of your app.
- Find your app in the Dashboard – use the search box if required.
- Click the name of your app. Note that due to naming restrictions some characters in your app name may have been changed or removed (such as the spaces in this example).
- Click Runtime in the menu.You can now change the number of instances, and the memory for each instance. You can also change the values of application constants, development mode, and scheduled events.
Memory and Instances
Any changes you make to the memory and instances configuration for the IBM Cloud runtime will be overwritten next time you deploy your app.
You can only make these changes permanent by creating a new environment from Mendix, or by changing the manifest.yml file in the IBM Repository for your app.
To change the memory and instances configuration temporarily, do the following:
- Increase or decrease the number of instances, or the memory per instance, using the +/- buttons.
- Click Save; the environment will be restarted to apply the new setting.You will get a warning that this change is not permanent – see the note above.
Environment Variables and App Constants
- Click Environment variables to change the environment variables.The environment variables contain three pieces of information which can be useful in managing your app. These are:
- DEVELOPMENT_MODE – this is true if you want the application to run with the Mendix security level of Prototype/demo, or Off (no security); it is recommended that this is changed to false for acceptance or production environments
- Constants within the app – these have the format *MX{module name}{constant name}
- SCHEDULED_EVENTS – by default, this is a comma separated list of all the scheduled events enabled in the app
- Change the values of these variables by typing the new values. Clicking Save will apply the new values and restart the environment.
Additional Resources
Full discussion of Mendix and environment variables in Cloud Foundry, see Run Mendix in Cloud Foundry in the cf-mendix-buildpack GitHub project