add docker support
This commit is contained in:
@@ -66,8 +66,11 @@ class ConfigurationService:
|
||||
def get_database_configuration(self) -> DatabaseConfiguration:
|
||||
try:
|
||||
return DatabaseConfiguration(
|
||||
database_address=self._config["database"]["database_address"],
|
||||
database_host=self._config["database"]["database_host"],
|
||||
database_port=self._config["database"]["database_port"],
|
||||
database_name=self._config["database"]["database_name"],
|
||||
database_user=self._config["database"]["database_user"],
|
||||
database_password=self._config["database"]["database_password"],
|
||||
)
|
||||
except KeyError:
|
||||
logger.fatal("Error loading DatabaseConfiguration, exiting...")
|
||||
|
||||
@@ -24,14 +24,24 @@ class DatabaseService:
|
||||
self._db_config = db_config
|
||||
self._client = None
|
||||
self._database = None
|
||||
self._users = None
|
||||
|
||||
async def initialize(self) -> None:
|
||||
mongo_uri = f"mongodb://{self._db_config.database_user}:{self._db_config.database_password}@{self._db_config.database_host}:{self._db_config.database_port}/{self._db_config.database_name}?authSource=admin"
|
||||
if self._client is None:
|
||||
self._client = AsyncMongoClient(self._db_config.database_address)
|
||||
self._database = self._client[self._db_config.database_name]
|
||||
self._users: AsyncCollection = self._database["users"]
|
||||
self._client = AsyncMongoClient(mongo_uri)
|
||||
|
||||
self._database = self._client[
|
||||
self._db_config.database_name
|
||||
]
|
||||
|
||||
await init_beanie(
|
||||
database=self._database,
|
||||
document_models=[User, Transaction, Ticket, Seat, CateringTypes.CateringMenuItem, CateringTypes.CateringOrder]
|
||||
document_models=[
|
||||
User,
|
||||
Transaction,
|
||||
Ticket,
|
||||
Seat,
|
||||
CateringTypes.CateringMenuItem,
|
||||
CateringTypes.CateringOrder
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user