From 3d7f92e20f64ebaa2f57847fb7b28580b2bb9641 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 3 Apr 2026 14:58:41 +0200 Subject: [PATCH] use hypercorn in production without uv bload --- Dockerfile | 8 ++++---- asgi.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 asgi.py diff --git a/Dockerfile b/Dockerfile index 446a06a..d0c0446 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim -# RUN apk add --no-cache build-base - # Install app COPY . /app WORKDIR /app @@ -9,5 +7,7 @@ WORKDIR /app # Install dependencies RUN uv sync --no-config --frozen --compile-bytecode -# Run Battlesnake -CMD ["uv", "run", "main.py"] +# Starten Sie Ihre Anwendung +EXPOSE 8000 + +CMD [".venv/bin/hypercorn", "asgi:app", "--bind", "0.0.0.0:8000", "--workers", "1", "--websocket-ping-interval", "20", "--access-logfile", "-"] diff --git a/asgi.py b/asgi.py new file mode 100644 index 0000000..f80a71c --- /dev/null +++ b/asgi.py @@ -0,0 +1,16 @@ +from server.Server import Server +import os + +server = Server( + data_path=os.path.dirname(__file__), + snake_type=os.environ.get("SNAKE", "BestBattleSnake"), + storage_type=os.environ.get("STORAGE", "LocalStorage"), + store_game_when_win_and_moves_are_bigger_as=int(os.environ.get("STORE_IF_WIN_AND_MOVES_ARE_BIGGER_AS", 10)), + debug=os.environ.get("DEBUG_SERVER", False), + check_tls_security=False, +) + +if os.environ.get("STORE_GAME_HISTORY", None): + server.enable_store_game_state() + +app = server.app