Skip to content

Commit

Permalink
- Added db creation.
Browse files Browse the repository at this point in the history
issue #37
  • Loading branch information
albamig committed Feb 23, 2022
1 parent c7f6455 commit fe5a3c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions microservice/language/python/init/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def build_deploy_playbook(path: Path) -> str:
def build_docker_compose(path: Path, microservice_name: str) -> str:
"""Build Docker Compose file content."""

db_creation_path = path / "external/10-create-database.sql"
if not db_creation_path.exists():
raise ValueError("external/postgres/10-create-database.sql script must exist")

with db_creation_path.open("a") as db_creation_file:
db_creation_file.write(f"\nCREATE DATABASE {microservice_name}_db")
db_creation_file.write(f"\nCREATE DATABASE {microservice_name}_query_db")

if not path.exists():
raise ValueError("A base Compose file must exist.")

Expand Down
4 changes: 2 additions & 2 deletions project/database/postgres/deploy/docker-compose/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def build_docker_compose(path: Path) -> str:
"build": "external/postgres",
"command": "postgres -c 'max_connections=200'",
"ports": ["5432"],
"volumes": ["postgres:/var/lib/postgresql/data",],
"environment": {"POSTGRES_USER": "minos", "POSTGRES_PASSWORD": "min0s",},
"volumes": ["postgres:/var/lib/postgresql/data", ],
"environment": {"POSTGRES_USER": "minos", "POSTGRES_PASSWORD": "min0s", },
}

data["services"]["postgres"] = container
Expand Down

0 comments on commit fe5a3c0

Please sign in to comment.