Skip to content

Commit

Permalink
fix: reverted to bind mounts as faster and easier to manage
Browse files Browse the repository at this point in the history
  • Loading branch information
Morriz committed Mar 8, 2024
1 parent 8892760 commit 52cb470
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ One can add additional docker properties to a service by adding them to the `add

```yaml
additional_properties:
cpu_count: 2
cpus: 0.1
```
The following docker service properties exist at the service root level and MUST NOT be added via `additional_properties`:
Expand Down
2 changes: 1 addition & 1 deletion db.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ projects:
env:
TARGET: boss
additional_properties:
cpu_count: 2
cpus: 0.1
- description: whoami service
domain: whoami.example.com
entrypoint: web
Expand Down
2 changes: 1 addition & 1 deletion lib/data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_upsert_env(self, mock_upsert_service: Mock, mock_get_service: Mock, moc
env=extra_env,
image="otomi/nodejs-helloworld:v1.2.13",
name="informant",
additional_properties={"cpu_count": 2},
additional_properties={"cpus": 0.1},
),
)

Expand Down
2 changes: 1 addition & 1 deletion lib/test_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
env={"TARGET": "boss"},
image="otomi/nodejs-helloworld:v1.2.13",
name="informant",
additional_properties={"cpu_count": 2},
additional_properties={"cpus": 0.1},
),
],
),
Expand Down
14 changes: 2 additions & 12 deletions lib/upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@
def write_upstream(project: Project) -> None:
with open("tpl/docker-compose.yml.j2", encoding="utf-8") as f:
tpl = f.read()
volumes = {}
for s in project.services:
vols = {}
for i, v in enumerate(s.volumes):
k = f"data_{s.name.replace('-', '_')}_{i}"
vols[k] = v
volumes[s.name] = vols

if os.environ.get("PYTHON_ENV") != "production":
content = Template(tpl).render(
project=project, volumes=volumes, domain=os.environ.get("TRAEFIK_DOMAIN"), env="development"
)
content = Template(tpl).render(project=project, domain=os.environ.get("TRAEFIK_DOMAIN"), env="development")
else:
content = Template(tpl).render(project=project, volumes=volumes, domain=project.domain)
content = Template(tpl).render(project=project, domain=project.domain)
with open(f"upstream/{project.name}/docker-compose.yml", "w", encoding="utf-8") as f:
f.write(content)

Expand Down
14 changes: 2 additions & 12 deletions tpl/docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,11 @@ services:
restart: unless-stopped
{%- if s.volumes %}
volumes:
{%- for k, v in volumes[s.name].items() %}
- {{ k }}:{{ v }}
{%- for v in s.volumes %}
- .{{ v }}:{{ v }}
{%- endfor %}
{%- endif %}
{%- for k, v in s.additional_properties.items() %}
{{ k }}: {{ v }}
{%- endfor %}
{%- endfor %}

{% if volumes|length > 0 %}
volumes:
{%- for s in project.services %}
{%- for k, v in volumes[s.name].items() %}
{{ k }}:
{%- endfor %}
{%- endfor %}
{%- endif %}

0 comments on commit 52cb470

Please sign in to comment.