Tecnativa / doodba-copier-template

A Copier template for Doodba projects
Boost Software License 1.0
88 stars 115 forks source link

[Opinion] Migrate to docker compose file version 3 and without extends, to support swarm deployment. #208

Open obayit opened 3 years ago

obayit commented 3 years ago

I thing it would be nice if the copier template is compatible with docker swarm out of the box.

Currently docker swarm requires a compose file of version 3.0 or higher, and it also doesn't support the extends key.

yajo commented 3 years ago

This never happened before because we didn't have a proper templating tool as we do today. It would be nice indeed.

obayit commented 3 years ago

Hi @Yajo , I started working on this, by using macros. For example, this macro is for volumes:

{%- macro common_yaml_odoo_volumes() %}
    volumes:
      - filestore:/var/lib/odoo:z
{%- endmacro %}

, I started working on this, by using macros. For example, this macro is for volumes:

{%- macro common_yaml_odoo_volumes() %}
    volumes:
      - filestore:/var/lib/odoo:z
{%- endmacro %}```

Then I use it in common.yaml like this:

services:
  odoo:
    ...
    {{ macros.common_yaml_odoo_volumes() }}

I plan to make a macro for every key like volumes and then use it in devel.yaml, prod.yaml and test.yaml. Am I going in the right direction?`` Then I use it incommon.yaml` like this:

services:
  odoo:
    ...
    {{ macros.common_yaml_odoo_volumes() }}

I plan to make a macro for every key like volumes and then use it in devel.yaml, prod.yaml and test.yaml. Am I going in the right direction? Edit: fixed code block syntax

yajo commented 3 years ago

It seems some of your macros broke your comment 😋

For what I can understand, if I were to use macros, I think common.yaml would disappear. For the rest, I guess you're right.

gdgellatly commented 3 years ago

I've kind of done this, although not using copier. In then end using a .env file like the old scaffolding just made more sense for the compose files.

I'd recommend having common.yaml -> docker-compose.yml, in .gitignore ignore docker-compose.override.yml and unignore docker-compose.yml, then just have 3 override files, linking for each environment. invoke develop then just links the test override file to be docker-compose.override.yml

yajo commented 3 years ago

It could be an option too. Although given Copier can generate any files and repeat any code comfortably, maybe the best would be to just generate those 3 environments completely and statically, allowing freedom for further overrides if needed.