diff --git a/Dockerfile b/Dockerfile index eae7c4e..2e168c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,8 @@ RUN pip install $(grep '^playwright==' requirements.txt | tr -d '\\') && playwri RUN pip install -r requirements.txt COPY --from=node-base --chown=appuser /app/dist/ ./src/static/flagwaver +ENV FLAGWAVER_PATH=/app/src/static/flagwaver + COPY src/ ./src USER appuser diff --git a/src/__main__.py b/src/__main__.py index 47534b9..ee8c77a 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -10,7 +10,6 @@ sys.path.append(os.path.dirname(__file__)) import asyncio import logging -from pathlib import Path from discord import Intents from pycord_rest import App @@ -36,13 +35,11 @@ app = App( default_command_integration_types={discord.IntegrationType.guild_install, discord.IntegrationType.user_install}, ) -FLAGWAVER_PATH = Path(__file__).parent / "flagwaver" / "dist" - async def main() -> None: async with ( RendererManager(num_workers=CONFIG.num_workers) as manager, - HttpServer(port=CONFIG.flagwaver_http_port, path=FLAGWAVER_PATH), + HttpServer(port=CONFIG.flagwaver_http_port, path=CONFIG.flagwaver_path), ): renderer = FlagRenderer(manager, f"http://localhost:{CONFIG.flagwaver_http_port}") app.add_cog(FlaggerCommands(app, manager, renderer)) diff --git a/src/config.py b/src/config.py index 03876d5..bd327c2 100644 --- a/src/config.py +++ b/src/config.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import os +from pathlib import Path from pydantic import BaseModel @@ -20,6 +21,7 @@ class Config(BaseModel): flagwaver_http_port: int = 8910 uvicorn_host: str = "0.0.0.0" # noqa: S104 auto_sync_commands: bool = True + flagwaver_path: Path CONFIG = Config( @@ -29,6 +31,7 @@ CONFIG = Config( flagwaver_http_port=int(os.getenv("FLAGWAVER_HTTP_PORT", "8910")), uvicorn_host=os.getenv("UVICORN_HOST", "0.0.0.0"), # noqa: S104 auto_sync_commands=os.getenv("AUTO_SYNC_COMMANDS", "true") == "true", + flagwaver_path=Path(os.getenv("FLAGWAVER_PATH", Path(__file__).parent / "flagwaver" / "dist")), ) __all__ = ["CONFIG"]