Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions credservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ COPY requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code and Alembic setup
# Copy the application code and scripts
COPY ./app ./app
COPY ./alembic ./alembic
COPY alembic.ini .
COPY ./scripts ./scripts

# Generate alembic.ini
RUN python scripts/generate_alembic_config.py

COPY run_service.sh .

# Make port 8001 available to the world outside this container
Expand Down
60 changes: 60 additions & 0 deletions credservice/scripts/generate_alembic_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""Script to generate alembic.ini configuration file."""

import os
from pathlib import Path

def generate_alembic_ini(output_dir: str = "."):
"""
Generate alembic.ini file in the specified directory.

Args:
output_dir: Directory where alembic.ini should be created
"""
content = """[alembic]
script_location = alembic

[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
"""

output_path = Path(output_dir) / "alembic.ini"
with open(output_path, "w") as f:
f.write(content)

print(f"✅ Generated alembic.ini at {output_path}")

if __name__ == "__main__":
# Get the project root (assuming script is in scripts directory)
project_root = Path(__file__).parent.parent
generate_alembic_ini(str(project_root))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SidPatel151 This is interesting that you added script to dynamically add the alembic.ini file. I am wondering what was your thought here? vs just creating a new alembic.ini and using it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to create it automatically, as at this time, I didn't notice the alembic.ini file in the gitignore. I also remember talking to you about making it autonomous to do. It's more efficient in my opinion as it creates the whole ini file for you when doing all the installations, instead oyu having to manually copy/paste it in or type one out.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies = [
"requests>=2.30.0", # HTTP client for API calls
"toml>=0.10.2", # TOML config file parsing
"pydantic>=2.0.0", # Data validation
"cryptography>=42.0.0", # Cryptographic primitives
]

[project.optional-dependencies]
Expand Down