This commit is contained in:
team3
2026-09-07 18:07:53 +02:00
parent 2a9ab4c7da
commit 778498d512
9 changed files with 245 additions and 390 deletions

View File

@@ -1,24 +1,30 @@
FROM python:3.12-slim
# Stage 1: Godot holen. Die Version steht hier, damit auf dem Server dieselbe
# läuft wie beim Entwickeln.
FROM debian:bookworm-slim AS godot
ARG GODOT_VERSION=4.7.2
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl unzip \
&& curl -fsSL -o /tmp/godot.zip \
"https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}-stable/Godot_v${GODOT_VERSION}-stable_linux.x86_64.zip" \
&& unzip -q /tmp/godot.zip -d /tmp \
&& mv "/tmp/Godot_v${GODOT_VERSION}-stable_linux.x86_64" /usr/local/bin/godot \
&& chmod +x /usr/local/bin/godot \
&& rm -rf /tmp/godot.zip /var/lib/apt/lists/*
# Stage 2: der Spielserver. Headless braucht kein X11 und kein OpenGL, Godot
# lädt die Bibliotheken erst bei Bedarf nach.
FROM debian:bookworm-slim
WORKDIR /app
COPY server/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Godot legt `make godot` in den Build-Kontext. Damit passt die Version auf
# dem Server exakt zu der, mit der das Spiel entwickelt wurde.
COPY dist/godot /usr/local/bin/godot
COPY --from=godot /usr/local/bin/godot /usr/local/bin/godot
COPY project.godot ./spiel/
COPY scenes ./spiel/scenes
COPY scripts ./spiel/scripts
COPY server/matchmaker.py ./
# Einmal beim Bauen importieren, sonst tut das der erste Raum - und der
# Spieler wartet.
RUN godot --headless --path /app/spiel --import
ENV GODOT=/usr/local/bin/godot
ENV SPIEL_PFAD=/app/spiel
EXPOSE 8000
CMD ["uvicorn", "matchmaker:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["godot", "--headless", "--path", "/app/spiel", "--", "server", "8000"]