-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service Templating #761
Comments
Could you provide some more context about the problem this is solving? Why would this template be used? |
My initial problem was that I needed a set of docker instances that are used for integration testing, development, and production. They are identical, except the integration testing configuration has docker links to each other, development has ports exposed, and the production configuration has ports exposed plus volumes configured. I had three fig.yml files that were mostly the same to achieve this and wasn't very happy with the set of non DRY yml files. I started writing code to generate the yml files based on a template, then realised changing fig itself is probably a better solution. Since then I realised that I've seen and had this problem before with fig (albeit on a smaller scale). e.g. devops creating nearly identical fig.yml files for staging and production, where the base image and hostnames were different, although #76 can solve that using environment variables, a templating system seems like a nicer solution to me since it is more explicit and doesn't need makefiles, etc. to set environment variables for fig. |
-> #988 may solve your issue. |
I guess this is a common feature request. :) I'm not bothering to pursue my patch since my implementation is a very small change, and there are more well thought out variations to it, especially #988. Closing. |
I need a feature where you can override a service with another. I've started the implementation and will create a pull request once I have a good set of tests done.
Here are the details:
Allows the ability to have templates, where your
fig.yml
can override anotherservice, optionally in another file (e.g.
template.yml
).template
can either be a string or dictionary.When
template
is a string, it specifies the path to the template, where thesame service name will be used.
When
template
is a dictionary, you may specifypath
andservice
as thekeys.
path
is the path to the template andservice
is the name of theservice to override in the specified template.
path
orservice
may beomitted defaulting to the same template file, or same service name.
For example, this would use
busybox:latest
with the command/bin/bash
(same as the other examples below):fig.yml
template.yml
Another example, this one runs in a single file:
fig.yml
A final example, referencing another file and service:
fig.yml
template.yml
I made a choice to have the "string" point to a template file rather than a service name (in the same file), only because that's how I plan to structure my fig files, so it was more appropriate as a default for my project.
The text was updated successfully, but these errors were encountered: