Maybe this is a little bit off-topic. I would like to ask how you manage your dockerfile.
I have a git repo hosting my configurations (docker-compose, traefik, etc). Then, I have a python script that reads data from JSON, renders the placeholder inside these files (the {{replace_me}}
) by an actual value and outputs them to another directory. Finally, I cd
to that directory and run docker-compose up -f ...
. (This approach takes inspiration from the terraform
templatefile
)
That JSON file is generated by some terraform code, along with terraform code for other stuffs (storage bucket, vps, dns, etc).
It works well for me so far. Especially for:
traefik toml
configuration (I like it a lot more than the label approach).secrect={{secret}}
.I know most templating docker part can be replaced by directly interpolating with environment variables but I don’t really like it because it seems environment variables are not persistent.
Do you have any suggestions for my workflow ? I am always feel a litte bit off about this approach.
Edit: Thank you for your suggestions. I will try k8s
for edge computing and if it does not work really well, I will stick with my current approach.
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.
Rules:
Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.
No spam posting.
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.
Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
No trolling.
Resources:
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Here is an ansible role that will create a compose file using variables passed in. ironicbadger/ansible-role-docker-compose-generator
I tried this but ended up using ansible directly to manage my containers.
I dont think Ansible is a general templating engine ? I do templating for all most everything and not only docker compose, for example this for traefik configuration.
fwiw Ansible uses Jinja under the hood, which itself is a templating engine.
That sounds like what I need. Thank you very much !