Skip to content

Commit

Permalink
feat: allow dict for depends_on, conf files
Browse files Browse the repository at this point in the history
  • Loading branch information
Morriz committed Oct 3, 2024
1 parent 587f3d0 commit b4d37f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
15 changes: 15 additions & 0 deletions conf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# extra conf folder

Put in any extra configuration for apps. Example:

```
zep/
config.yaml
```

And then reference those from `db.yaml` like this:

```yaml
volumes:
- ../../conf/zep/zep.yaml:/app/zep.yaml
```
2 changes: 1 addition & 1 deletion lib/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Service(BaseModel):
"""Additional docker compose properties to pass to the service"""
command: str = None
"""The command to run in the service"""
depends_on: List[str] = []
depends_on: List[str] | Dict[str, Any] = []
"""A list of services to depend on"""
env: Env = Env()
"""A dictionary of environment variables to pass to the service"""
Expand Down
30 changes: 18 additions & 12 deletions tpl/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ services:
{%- if s.command %}
command: {{ s.command }}
{%- endif %}
{%- if s.depends_on | length > 0 %}
{%- if s.depends_on %}
depends_on:
{%- for dep in s.depends_on %}
{%- if s.depends_on is mapping %}
{%- for key, dep in s.depends_on.items() %}
{{ project.name }}-{{ key }}:
{{ dep }}
{%- endfor %}
{%- else %}
{%- for dep in s.depends_on %}
- {{ project.name }}-{{ dep }}
{%- endfor %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- if s.env.model_dump() | length > 0 %}
environment:
Expand Down Expand Up @@ -47,14 +54,11 @@ services:
{%- if i.router != Router.udp %}
{%- set domains = ([i.tls.main] + i.tls.sans) if (i.tls and i.tls.main) else [i.domain] %}
- traefik.{{ router }}.routers.{{ name }}.rule={% for d in domains %}Host{% if i.router == Router.tcp %}SNI{% endif %}(`{{ d }}`){% if not loop.last %} || {% endif %}{% endfor %}{% if i.path_prefix %} && PathPrefix(`{{ i.path_prefix }}`){% endif %}
{%- if i.tls %}
- traefik.{{ router }}.routers.{{ name }}.tls.certresolver=letsencrypt
{%- if i.tls.main %}
{%- if i.tls and i.tls.main %}
- traefik.{{ router }}.routers.{{ name }}.tls.domains[0].main={{ i.tls.main }}
{%- for s in i.tls.sans %}
{%- for s in i.tls.sans %}
- traefik.{{ router }}.routers.{{ name }}.tls.domains[0].sans[{{ loop.index0 }}]={{ s }}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
- traefik.{{ router }}.routers.{{ name }}.service={{ name }}
Expand All @@ -69,12 +73,14 @@ services:
- {{ l }}
{%- endfor %}
{%- endif %}
{%- if has_ingress or p.services | length > 1 %}
networks:
{%- if p.services | length > 1 %}
{%- if p.services | length > 1 %}
- default
{%- endif %}
{%- if has_ingress %}
{%- endif %}
{%- if has_ingress %}
- proxynet
{%- endif %}
{%- endif %}
restart: {{ s.restart }}
{%- if s.volumes %}
Expand Down

0 comments on commit b4d37f9

Please # to comment.