add docker support
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
FROM python:3.12-bookworm
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt install dumb-init
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
EXPOSE 8001
|
||||||
|
EXPOSE 8090
|
||||||
|
EXPOSE 8091
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
+4
-1
@@ -11,7 +11,10 @@
|
|||||||
discord_invite_link=""
|
discord_invite_link=""
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
db_address="mongodb://localhost:27017"
|
database_host="localhost"
|
||||||
|
database_port="27017"
|
||||||
|
database_user="root"
|
||||||
|
database_password="password"
|
||||||
database_name="elm"
|
database_name="elm"
|
||||||
|
|
||||||
[mailing]
|
[mailing]
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: /opt/elm
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
- "8001:8001"
|
||||||
|
volumes:
|
||||||
|
- ./:/opt/elm
|
||||||
|
entrypoint: ["/bin/sh", "-c", "cd /opt/elm/src && rio run --release --public --port 8000"]
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mongo:8
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
environment:
|
||||||
|
MONGO_INITDB_ROOT_USERNAME: elm
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: elm
|
||||||
|
MONGO_INITDB_DATABASE: elm
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- database:/data/db
|
||||||
|
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 15s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
||||||
@@ -66,8 +66,11 @@ class ConfigurationService:
|
|||||||
def get_database_configuration(self) -> DatabaseConfiguration:
|
def get_database_configuration(self) -> DatabaseConfiguration:
|
||||||
try:
|
try:
|
||||||
return DatabaseConfiguration(
|
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_name=self._config["database"]["database_name"],
|
||||||
|
database_user=self._config["database"]["database_user"],
|
||||||
|
database_password=self._config["database"]["database_password"],
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.fatal("Error loading DatabaseConfiguration, exiting...")
|
logger.fatal("Error loading DatabaseConfiguration, exiting...")
|
||||||
|
|||||||
@@ -24,14 +24,24 @@ class DatabaseService:
|
|||||||
self._db_config = db_config
|
self._db_config = db_config
|
||||||
self._client = None
|
self._client = None
|
||||||
self._database = None
|
self._database = None
|
||||||
self._users = None
|
|
||||||
|
|
||||||
async def initialize(self) -> 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:
|
if self._client is None:
|
||||||
self._client = AsyncMongoClient(self._db_config.database_address)
|
self._client = AsyncMongoClient(mongo_uri)
|
||||||
self._database = self._client[self._db_config.database_name]
|
|
||||||
self._users: AsyncCollection = self._database["users"]
|
self._database = self._client[
|
||||||
|
self._db_config.database_name
|
||||||
|
]
|
||||||
|
|
||||||
await init_beanie(
|
await init_beanie(
|
||||||
database=self._database,
|
database=self._database,
|
||||||
document_models=[User, Transaction, Ticket, Seat, CateringTypes.CateringMenuItem, CateringTypes.CateringOrder]
|
document_models=[
|
||||||
|
User,
|
||||||
|
Transaction,
|
||||||
|
Ticket,
|
||||||
|
Seat,
|
||||||
|
CateringTypes.CateringMenuItem,
|
||||||
|
CateringTypes.CateringOrder
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ class MailingServiceConfiguration:
|
|||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class DatabaseConfiguration:
|
class DatabaseConfiguration:
|
||||||
database_address: str
|
database_host: str
|
||||||
|
database_port: str
|
||||||
database_name: str
|
database_name: str
|
||||||
|
database_user: str
|
||||||
|
database_password :str
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class LanInfo:
|
class LanInfo:
|
||||||
|
|||||||
Reference in New Issue
Block a user