I was interested to know if there is a Gekko container available. Idea is to have a gekko MPC in a docker that can be easily configured with an interface to load a model, do tuning and visualize the results for a realtime application.
CodePudding user response:
Here is a tutorial on how to Dockerize a Python program that is run from a Command Line Interface (CLI). Include gekko
in the requirements.txt file. This uses a minimal version of Python that is designed for docker containers.
FROM python:3.9-slim
RUN useradd --create-home --shell /bin/bash app_user
WORKDIR /home/app_user
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
USER app_user
COPY . .
CMD ["bash"]
There is also a two part series on how to package applications in a Docker container with Part 1 - Using Docker Desktop and Docker Hub and How to Build and Test Your Docker Images in the Cloud with Docker Hub.
A few things to consider:
- Include
m.path
(GEKKO run-time directory) in the Docker PATH: Compiling Gekko with Pyinstaller Them._path
value can be changed from thetmp
directory to something else. - More information about the Gekko run directory: Gekko Python: Any way to export the model for debugging purposes?
- The Gekko GUI requires Flask webserver and other components to run: How do I display solution in GEKKO GUI? This will increase the size and complexity of the Docker container.
- Include communication protocols such as Modbus or OPC UA to read and write values to and from a Programmable Logic Controller or Distributed Control System.
Every MPC application that I've created is so customized with a particular model for a particular application that it doesn't seem practical to create a general-purpose Docker container. If the application can be developed once and copied to many similar systems (e.g. MPC to replace PID control) then a Docker container may make sense to ease deployment.