Best Practices¶
Configure Environment Variables¶
Mendix applications on Industrial Edge support configuration files. You can add a configuration file with specific environment variables for each Edge device in addition to the standard variables configured in the docker-compose file. That allows the end user of your application to individually adapt the application to dedicated devices.
The container searches the location specified in the environment variable IEM_CONFIG_PATH
for files with the .env
extension. The .env files can contain one or more environment variables to be added to the container's environment variables. This can be used to set specific constants, scheduled events, or custom runtime settings for Edge devices.
In the following section, you'll find an example Compose file with the IEM_CONFIG_PATH
set to the volume /configurations.
Exemplary .env file:
ADMIN_PASSWORD=************
Using Constants¶
The default values for constants will be used as defined in your project. However, you can override them with environment variables. You need to replace the dot with an underscore and prefix it with MX_ . So a constant like MyFirstModule.AppPath with value https://127.0.0.1:32900 could be set like this:
MX_MyFirstModule_AppPath="https://127.0.0.1:32900"
Communicating with other Industrial Edge Devices¶
NOTICE
When your app needs to interact with APIs of other IEDs, an IED certificate is required.
Workarounds:
Development and testing in Mendix Studio Pro:
- During development: add public certificates in "App Settings" of Mendix Studio Pro for all Edge Devices that need to be called by the app Deployment on Edge Device:
- When running the Mendix app as a Docker container built with mendix-docker-buildpack >= 3.4.0 (using cf buildpack >= 4.20.0): Add the
CERTIFICATE_AUTHORITIES_BASE64
environment variable with the encoded chain of public certificates to be used. There are two ways to do this: - Include a file with a .env extension as configuration when running Mendix as an Industrial Edge app. This file should contain
CERTIFICATE_AUTHORITIES_BASE64
as described before. or - Add the variable
CERTIFICATE_AUTHORITIES_BASE64
directly to the docker-compose.yml.
To illustrate the generation of an encoded chain for your devices, use the following command to generate a chain for two devices:
printf "\nCERTIFICATE_AUTHORITIES_BASE64=\"$({ openssl s_client -connect <IED_ID>:443 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' & printf "\n" & openssl s_client -connect <IED_ID>:443 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'; } | base64 -w 0)\"\n" >> test.env
Example docker-compose.yml¶
version: '2.4'
services:
mendix:
image: your-mendix-image:latest
environment:
ADMIN_PASSWORD: ************
MXRUNTIME_DatabaseType: MYSQL
MXRUNTIME_DatabaseHost: mysql
MXRUNTIME_DatabasePort: 3306
MXRUNTIME_DatabaseName: your_mendix_db
MXRUNTIME_DatabaseUserName: your_db_user
MXRUNTIME_DatabasePassword: your_db_password
CERTIFICATE_AUTHORITIES_BASE64: >-
<BASE64 ENCODED VALUE>
IEM_CONFIG_PATH: /configurations
ports:
- '60000:8080'
mem_limit: 1gb
volumes:
- './configurations/:/configurations/'
mysql:
image: mysql:latest
environment:
MYSQL_DATABASE: your_mendix_db
MYSQL_USER: your_db_user
MYSQL_PASSWORD: your_db_password
MYSQL_ROOT_PASSWORD: your_root_password
volumes:
- mysql-data:/var/lib/mysql
mem_limit: 600mb
volumes:
mysql-data:
Supported Runtime Databases¶
In the context of Mendix for Docker, a runtime database refers to the database system that your Mendix application uses to store and manage its data when deployed in a Docker container. The runtime database is where your application's entities, attributes, records, and relationships are persisted.
When you deploy a Mendix application in a Docker container, you have the flexibility to choose the type of database system you want to use as the runtime database. Mendix supports various database systems, including built-in databases (like HSQLDB), as well as external relational databases (like MySQL, PostgreSQL, and Microsoft SQL Server).
The choice of the runtime database is a crucial decision when deploying Mendix applications, as it can impact the performance, scalability, and maintainability of your application.
Mendix App with built-in Database¶
NOTICE
Not supported for Industrial Edge! No persistent data!
The built-in database that Mendix uses for development and testing purposes is called "HSQLDB," which stands for HyperSQL Database. HSQLDB is an open-source relational database management system written in Java. It's known for being lightweight and embeddable, making it suitable for use within applications.
In the context of Mendix, HSQLDB is often used during development and testing phases when you don't want to set up a separate external database like MySQL, PostgreSQL, or Microsoft SQL Server. HSQLDB provides basic database functionality and allows developers to interact with data using SQL queries. It's particularly useful for rapidly developing and iterating on applications before deploying them to production.
While HSQLDB is suitable for development and testing, it might not be as performant, scalable, or feature-rich as dedicated database systems. When deploying Mendix applications in production, it's recommended to use a more robust and scalable database system to ensure optimal performance and data integrity.
Mendix App with dedicated Database Service¶
For production environments, Mendix recommends using external relational databases, such as MySQL, PostgreSQL, or Microsoft SQL Server. These databases offer better performance, scalability, and data integrity compared to the built-in HSQLDB.
Using a MySQL service¶
The following docker-compose.yml is also provided as a template in the Industrial Edge plugin.
version: '2.4'
services:
mendix:
image: your-mendix-image:latest
environment:
ADMIN_PASSWORD: ************
MXRUNTIME_DatabaseType: MYSQL
MXRUNTIME_DatabaseHost: mysql
MXRUNTIME_DatabasePort: 3306
MXRUNTIME_DatabaseName: your_mendix_db
MXRUNTIME_DatabaseUserName: your_db_user
MXRUNTIME_DatabasePassword: your_db_password
ports:
- '60000:8080'
mem_limit: 1gb
mysql:
image: mysql:latest
environment:
MYSQL_DATABASE: your_mendix_db
MYSQL_USER: your_db_user
MYSQL_PASSWORD: your_db_password
MYSQL_ROOT_PASSWORD: your_root_password
volumes:
- mysql-data:/var/lib/mysql
mem_limit: 600mb
volumes:
mysql-data:
Known Issues Industrial Edge Plugin¶
Q: How to resolve the "repository already exists error" ?
Ans: The app repository name is unique. If this error occurs, please go to your Mendix project directory and delete the workspace folder($projectdirectory//workspace). Relaunch the plugin and create a new application with different repo name.Q: Does the Industrial Edge Plugin works with multiple instances of mendix studio pro ?
Ans: No, the Industrial Edge Plugin does not work with multiple instances of Mendix Studio pro. Use plugin with one instance of Mendix Studio Pro at a timeQ: How to resolve "path too long error" during version creation, export, or upload ?
Ans: Follow this link for the [workaround](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later) .Q: What to do if you are not able to upload a specific application version to your IEM ?
or if you are getting this error while uploading : "Something went wrong...can not perform requested operation."- Case 1: There are chances that an application with the same AppID exists on your IEM in a "deleted" state. Thus, try to change the application ID and upload again.
- Case 2: You deleted your local app but creating new applications for the same Mendix app again (application already exists on IEM with same ID and version). Try to change the application ID and upload again.