Compare commits
2 Commits
c62c0d0157
...
792a7878f0
Author | SHA1 | Date | |
---|---|---|---|
792a7878f0 | |||
![]() |
411c3c91b2 |
@ -47,6 +47,8 @@ WORKDIR /app
|
||||
COPY --chown=appuser:appuser app/ ./app/
|
||||
COPY --chown=appuser:appuser *.py ./
|
||||
COPY --chown=appuser:appuser requirements.txt ./
|
||||
COPY --chown=appuser:appuser alembic.ini ./
|
||||
COPY --chown=appuser:appuser alembic/ ./alembic/
|
||||
|
||||
# Create logs directory
|
||||
RUN mkdir -p /app/logs && chown -R appuser:appuser /app
|
||||
|
@ -9,6 +9,9 @@ from sentry_sdk.integrations.fastapi import FastApiIntegration
|
||||
from fastapi_users.authentication import JWTStrategy
|
||||
from pydantic import BaseModel
|
||||
from jose import jwt, JWTError
|
||||
from alembic.config import Config
|
||||
from alembic import command
|
||||
import os
|
||||
|
||||
from app.api.api_router import api_router
|
||||
from app.config import settings
|
||||
@ -216,8 +219,17 @@ async def read_root():
|
||||
async def startup_event():
|
||||
"""Initialize services on startup."""
|
||||
logger.info(f"Application startup in {settings.ENVIRONMENT} environment...")
|
||||
# You might perform initial checks or warm-up here
|
||||
# await database.engine.connect() # Example check (get_db handles sessions per request)
|
||||
|
||||
# Run database migrations
|
||||
try:
|
||||
logger.info("Running database migrations...")
|
||||
alembic_cfg = Config("alembic.ini")
|
||||
command.upgrade(alembic_cfg, "head")
|
||||
logger.info("Database migrations completed successfully.")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to run database migrations: {e}")
|
||||
raise
|
||||
|
||||
init_scheduler()
|
||||
logger.info("Application startup complete.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user