Version: 0.1.0
Note: This is work in progress and should not be used for any production setup. This README is not finished yet. See TODO (bottom of this README) for all steps that are still in development. We do not take responsibility if your Raspberry Pi decides to take over the world.
This is not supported by Mendix, purely a proof-of-concept created by two Mendix developers.
The Mendix Balena Buildpack allows you to run a Mendix application on a Raspberry Pi 3. We do this by forking the official Mendix build pack so that it will run on ARM and combining this with a ready-to-go configuration of NGINX & PostgreSQL in separate containers on the Raspberry Pi.
This modified buildpack also contains WiringPi (version 2.46.1, included) & Pi4J (version 1.2-SNAPSHOT, included), so we can control GPIO ports from Java Actions in Mendix. The separate module can be found here
It is based on the following sources:
- Mendix Buildpack for Docker - this is the forked Mendix Docker buildpack made to run on ARM
- Mendix Buildpack for Cloud Foundry - this is modified and will be downloaded as part of the Docker buildpack flow.
- Balena Raspberry Pi3 Ubuntu base image with OpenJDK
- Create an account on Balena.io, create an application for Raspberry Pi 3 and burn the image on an SD. Have a look at the How-to describing setting this up for NodeJS. Follow the steps up to (and included) Provision device. From there on out, we will follow the steps that are described below.
- Clone this repository from Github to your computer
- Add the balena remote to this respository:
git remote add balena <username>@git.balena-cloud.com:<username>/<repo>.git
. You can find this command in the top right of your Balena dashboard in an app. - Create a deployment package for your application in Mendix Modeler.
- Take the .MDA file and unzip it in the project folder in
docker-mendix-buildpack/project
. Your project folder should contain two folders:web
&model
. - Now copy the
web
folder to the nginx folder in this buildpack. This is needed to serve static files.
Your repository should have the following (partial) structure (leave all other folder and files AS IS):
├── docker-compose.yml
├── docker-mendix-buildpack
│ └── project
│ ├── web <web-folder from deployment>
│ └── model <model-folder from deployment>
└── nginx
└── web <web-folder from deployment>
- Make changes to the Docker compose file, adding a License ID & Key (if necessary), your admin password, maybe a remote database. Note: You can also put these as ENVIRONMENT variables in your Balena configuration (which is preferable instead of putting this in the configuration files itself). See Environment and service variables on Balena.io
- Now add everything to a commit:
git add --all :/
andgit commit -m "Commit message"
- Push it to Balena:
git push balena master
- See the magic happening
This section is not finished yet
It is possible, using the Balena Cli, to build the Docker images locally. This will fix problems with the build server ARM1, which sometimes fails. Images are stored in your local Docker repo (on your computer). We're also checking if it will be possible to put this image on Docker Hub to make development easier.
- Make sure Docker is running on your computer
- Make sure Balena Cli is installed on your computer and you are logged in.
- Run the following command:
balena build --deviceType raspberrypi3 --arch armv7hf --emulated --verbose --logs
- This will build all the images and store them in your local Docker
- Make sure the build in the previous step is succesful
- Deploy to Balena with the following command:
balena deploy <username>/<app-name>
See for further instructions Balena Cli Docs
CONCEPT: not ready yet
This isn't finished yet, but the authors were able to create a CI/CD pipeline in Azure Devops, so you can just commit to the Teamserver in Mendix and it will automatically deploy to Balena. This will be updated once we have finished up the writeup for this. Right now this is using undocumented tools to download a deployment package, for which it is unable to be documented yet.
This project is a proof of concept. The following things are on the todo list:
- Use the MDA file instead of the unzipped contents
Check if we need the web folder (static content) in the mendix buildpack, or only in NGINXWeb folder is needed- Finish up the RPI Module for Mendix which can be found here: https://github.com/JelteMX/RaspberryPiModule
docker-compose.yml
includes a reference to a container for Google Cloud IOT, which is a way to send data to Google Cloud IOT. This component needs further development before it can be reliably used.- We will update the Dockerfile in the Mendix buildpack to become a
Dockerfile.template
, making it possible to run it on other devices as well. - See if we can host the specific Mendix image on Docker Hub, so we don't have to include the current complex Dockerfile setup