Add logging to basic_example and update PostgreSQL database name

This commit is contained in:
2025-06-18 04:41:49 +02:00
parent 2e000017e4
commit 2996016aee
2 changed files with 21 additions and 2 deletions

12
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"cSpell.words": [
"docstrings",
"healthcheck",
"isort",
"pycodestyle",
"pydantic",
"pydocstyle",
"pytest",
"pyyaml"
]
}

View File

@ -1,7 +1,14 @@
"""Example usage of DockerComposeManager to generate a docker-compose.yaml file."""
from __future__ import annotations
import logging
from compose import DockerComposeManager
logging.basicConfig(level=logging.DEBUG)
logger: logging.Logger = logging.getLogger("docker-compose-example")
if __name__ == "__main__":
# Path to the compose file to generate
compose_path = "docker-compose.yaml"
@ -24,7 +31,7 @@ if __name__ == "__main__":
environment={
"POSTGRES_USER": "user",
"POSTGRES_PASSWORD": "password",
"POSTGRES_DB": "exampledb",
"POSTGRES_DB": "example_db",
},
ports=["5432:5432"],
volumes=["db_data:/var/lib/postgresql/data"],
@ -33,4 +40,4 @@ if __name__ == "__main__":
# Save the compose file
manager.save()
print(f"docker-compose.yaml generated at {compose_path}")
logger.info("docker-compose.yaml generated at %s", compose_path)