this post was submitted on 14 Jul 2023
12 points (83.3% liked)

Selfhosted

40219 readers
953 users here now

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:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. 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.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

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:

  • templating traefik toml configuration (I like it a lot more than the label approach).
  • secret in the docker env file (so my docker.env file has the form of 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.

you are viewing a single comment's thread
view the rest of the comments
[–] Fenzik@lemmy.ml 2 points 1 year ago* (last edited 1 year ago) (3 children)

So far I just hand roll my docker-compose (at home, anyway). However, docker-compose does also support overrides via yaml merging, maybe that’s worth looking into?

My idea with that is to have a base compose that configures also my services and then to have a few override yamls with environment specific stuff (like prod, local, …)

This is similar to Kustomize from kubernetes land which I’ve worked with in the past

[–] lyoko@lemm.ee 3 points 1 year ago (1 children)

I actually need more than merging. For example, right now my traefik.template will look like this:

[http.routers.{{ router_name }}]
  rule = "{{ router_rule }}"
  service = "{{ service_name }}"
  middlewares = [{{ middlewares | map("tojson") | join(", ") }}]
{% block router %}{% endblock %}
  [http.routers.{{ router_name }}.tls]
    certResolver = "leresolver_http"

{% if service_host is defined %}
[[http.services.{{ service_name }}.loadBalancer.servers]]
  url = "{{ 'https' if service_use_https is defined else 'http' }}://{{ service_host }}{{ ':' ~ service_port if service_port is defined else '' }}"
{% endif %}

and then one of my traefik.toml could look like this

{% extends "template/traefik.jinja" %}

{% set router_name = "dozzle" %}
{% set router_rule = "Host(`dozzle.example.com`)" %}
{% set service_name = "dozzle" %}
{% set service_host = "dozzle" %}
{% set service_port = 8080 %}
[–] Fenzik@lemmy.ml 2 points 1 year ago

This is definitely a job for templating, seems you’ve got the right tool to me!

load more comments (1 replies)