There are two types of configurations related to configuring services.
1- Configuring service tasks/events, it’s public ports, data volumes etc. from the mesg.yml. (we have this feature).
2- Configuring service’s program with its own runtime cli flags. (we do this within the Dockerfile of service while running it.)
Currently, these two types of configurations can be only done by changing the source code of services. And we don’t support ability of somehow setting cli flags of service’s program within the mesg.yml file. Since mesg.yml is the place where we describe and configure services, I think, we should also support configuring runtime of service’s program inside of it too.
Purpose if this proposal is to discuss both to support configuring services dynamically without changing their source code by using some kind of runtime or build-time arguments for MESG services. If we have this feature, as a second, we can support providing configurations to runtime of service’s program, this way program can be dynamically configured as well.
Real world case about why this is needed:
As a user, let’s say that I have a workflow file and I want to use service-http-server for serving a vuejs app and a rest api but from different ports. To do that, service-http-server should be configurable to set a port address without a need of changing its source code because, I don’t want to fork it and create two different branches to setup different ports. I want to have the full power of reusable services by passing configurations dynamically.
Check the sample mesg.yml and Dockerfile below for see this proposal in actual code:
- Note that, to configure service’s program dynamically from the mesg.yml, I followed the pattern of using build args of Docker. Every arg provided while deploying/starting MESG services also directly mapped to Docker’s build time args
$ mesg-core service deploy --arg serverAddr=2300 https://github.com/ilgooz/service-http-server // outputs a SERVICE_ID // or $ mesg-core service start --arg serverAddr=2300 SERVICE_ID // outputs an ANOTHER_SERVICE_ID
... name: ... description: ... env: # we can also support env vars that will be accessed by service's program on runtime # as next to configuring service's program with Docker's build time args. AN_ENV_VAR: 123 configuration: ports: - $serverAddr ...
CMD website --serverAddr $serverAddr
We discussed on Discord and kinda agreed on providing runtime arguments to MESG services with the service start/deploy command and they can be accessed with $ sign in the yml file. Every argument should be also mapped to Docker’s build time arguments. But of course, every change on args must cause service to get a different service id.
By having this configuration features, we can also support giving configurations for services in the workflow files easily like this:
... services: website: id: https://github.com/ilgooz/service-http-server/ args: serverAddr: 2300 restapi: repo: https://github.com/ilgooz/service-http-server/ args: serverAddr: 3300 when: ...