Skip to content

Commit

Permalink
add alembic config, get db url from app settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nitekot committed Aug 29, 2024
1 parent 84dc648 commit 606c147
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

WORKDIR /project

# app source files
COPY sync.py .
COPY aggregator.py .
COPY alembic ./alembic
COPY app ./app

# db migrations files
COPY alembic ./alembic
COPY docs/alembic.example.ini ./alembic.ini

CMD uvicorn app:create_app --host 0.0.0.0 --port 8000
5 changes: 4 additions & 1 deletion alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from alembic import context

from app.models import Base
from app.utils import get_settings


# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand All @@ -28,7 +30,8 @@
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.

settings = get_settings()
config.set_main_option('sqlalchemy.url', settings.database.endpoint)

def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
Expand Down

0 comments on commit 606c147

Please sign in to comment.