In this tutorial, you will see how you can run Maestro Framework apps inside a Docker container. Maestro Framework is just another .NET 8 application, so you just have to build a Docker image for that, include all the necessary files, and use the HTTP endpoint to start and monitor each Maestro app. The HTTP endpoint is provided in the Maestro Web project, an ASP.NET web API. This tutorial requires that you know how to operate Docker and have worked with REST APIs before (with Swagger). Needless to say, Docker must be installed and working properly in order to run apps inside a container.
Download the Maestro Framework and use .NET 8 SDK to build the solution, as instructed in Readme.txt.
Download the Maestro Web project and extract it to a folder called "ContainerImage". This project is free and open-source, and is available as an example showing how you could host Maestro Framework inside a REST API.
Copy the LogicAppRunner.dll and all its dependencies from the build output folder from Step 1 to the following subpath inside ContainerImage: ./Data/Maestro
Copy the application or applications you wish to be able to run with Maestro to the ./Data/Apps folder inside ContainerImage. Make sure each application lives in its own folder with the folder name exactly the same as the application's executable .txt file. For example, if you have an app with logic inside LogicApp1.txt, make sure the folder name is LogicApp1. There is an example application here - OlispImport. The app produces output in Output.txt in the app folder. You can extract the example application into a new 'OlispImport' subfolder in ./Data/Apps.
First, create your Dockerfile in the ContainerImage folder or download the Dockerfile provided as an example here.
Next, run the following command at the terminal, from the ContainerImage folder:
docker build -t maestro-image -f Dockerfile .
Now that you've got the container image created, the next step is to create your container.
Use the following command at the terminal:
docker create --name maestro-run maestro-image
You can now start the container and the Maestro Web API using the following terminal command:
docker start maestro-run
(Later to stop it just run "docker stop maestro-run")
To access the API, we need to know what the IP address of our container is.
First, run the following terminal command:
docker ps
This will list all containers currently running. You can get your container ID from there.
Next, you need to run the following terminal command:
docker inspect <container_id>
From the console output, you should be able to find an IP address, like: 127.0.0.1
In your web browser, type http://<ip_address>:8080/swagger
You'll be able to use the Swagger UI to use the API.
The first thing you should do is to authenticate. Maestro Web provides a few built-in API keys (license keys) in the Data/appkeys.txt file. Use the /user POST endpoint to create a user (with password) based on one of the license keys. Note - You can also use the built-in test user, with username "test" and password "abc123". To secure a production container, we recommend not copying over the appkeys.txt file AND getting rid of the test user in Data/users.txt.
Run the /auth/createToken endpoint with the username and password of your choice. You will get back a JWT token. Copy this token (CTRL+C) and click the Authorize button at the top of the page. Paste the token in the popup that shows up. Make sure you get rid of the quotes (").
Now that you've got yourself authenticated, you can run one of your apps. Go to the /start endpoint and enter the app's name (case sensitive), e.g. LogicApp1. Execute that endpoint. Your app will run inside the container.
If your app produces console output, unfortunately it will be hard to read from the container. You will need to produce a file, at minimum, as your output.
Now, if your app does have a file as its output, you can grab that file from inside the container.
Just use the following terminal command on the host:
docker cp <containerId>:/file/path/within/container /host/path/target
In the case of our example OlispImport app:
docker cp <containerId>:/App/Data/Apps/OlispImport/Output.txt ./out.txt
In production, we recommend that your app push output to HTTPS endpoints or upload files to SFTP/Azure Storage for ease of use and security. Maestro Framework makes it easy, as it provides built-in interactions for both HTTP(S) and SFTP.
Is running logic apps inside Docker containers the recommended way? In most cases, you can just run the apps locally as they should be fairly safe. However, if your app interacts with an AI or has any sort of agency where its logic can vary from what is specified in the .txt file, it is HIGHLY recommended that you run the app inside a container.
Also, if you wish to make your application executable remotely, from anywhere in the world, through an HTTPS endpoint, your best choice is to deploy it inside a container like shown in this tutorial. There are still hurdles to overcome with regards to making Maestro Framework CI/CD friendly, so for now you'll have to copy binaries (DLLs) as shown in this tutorial.
You may be able to get better CI/CD integration if you build LogicAppRunner from scratch and copy it over in your deployment pipeline. That is also an option.
Finally, please be mindful of the license restrictions of Maestro Framework, which (unless you've purchased a commercial license), do not allow for commercial uses.