BlackZork / mqmgateway

MQTT gateway for modbus networks
GNU Affero General Public License v3.0
42 stars 18 forks source link

Docker support with GitHub CI build #28

Closed git-developer closed 7 months ago

git-developer commented 1 year ago

This PR is a proof-of-concept for a CI build of a Docker image on GitHub. It is has three parts:

Build

The Dockerfile describes the build of an image. After downloading a base image of Alpine Linux and all required dependencies incl. exprtk, the C++ build is started and the tests are run. When that succeeds, the binaries are taken over into a new small image that only includes the runtime dependencies.

Continuous Integration

Whenever a commit is reaching branch feature/ci, a workflow is started via GitHub Actions. The workflow creates a Docker image for five platforms in parallel (multi-arch). When the build of an image succeeds, the image is pushed to the GitHub Container Registry. The image name is derived from the Git repository. When all builds succeed, a manifest list is created for the branch, so that the same image name may be used on any platform, e.g. ghcr.io/BlackZork/mqmgateway:feature-ci. The images are shown in GitHub on the right side of the repository in section Packages.

Runtime

The docker-compose.yml is the only file that a user requires to run the application, apart from a configuration file config.yaml expected in the same directory. The devices for Modbus RTU may be configured in the compose file. The application can be managed and monitored with standard compose commands, e.g. docker compose up to start or docker compose logs to view the logs.

Notes

git-developer commented 1 year ago

Disclaimer: the workflow file is based on an example from the Docker docs.