diff --git a/Dockerfile b/Dockerfile index 93a0504..0fe3da6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,19 +5,19 @@ WORKDIR /app # Install uv RUN pip install --no-cache-dir uv -# Copy project files +# Install dependencies first (cached unless the lockfile changes) COPY pyproject.toml uv.lock ./ - -# Install dependencies with uv -RUN uv sync --no-editable +RUN uv sync --frozen --no-install-project # Copy source code -COPY solve.py web_solve.py ./ -COPY templates/ templates/ +COPY solve.py main.py index.html ./ -# Set environment variables -ENV FLASK_APP=web_solve.py -ENV PYTHONUNBUFFERED=1 +# Bind to all interfaces so the server is reachable outside the container +ENV HOST=0.0.0.0 \ + PORT=8000 \ + PYTHONUNBUFFERED=1 -# Run Flask app -CMD ["uv", "run", "python", "web_solve.py"] +EXPOSE 8000 + +# Run the stdlib HTTP server +CMD ["uv", "run", "--frozen", "python", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml index 6ad89a1..e3f59d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,9 @@ -version: '3.8' - services: web: build: . ports: - - "5555:5000" + - "8000:8000" environment: - - FLASK_ENV=development - - FLASK_DEBUG=1 - volumes: - - .:/app - command: uv run python web_solve.py + - HOST=0.0.0.0 + - PORT=8000 restart: unless-stopped diff --git a/main.py b/main.py index 6f2e7b4..3ce30e5 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,7 @@ once, then calls it over the amounts it needs (0..max_resource) to build the from __future__ import annotations import json +import os from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path @@ -58,7 +59,8 @@ class Handler(BaseHTTPRequestHandler): def main(): - host, port = "127.0.0.1", 8000 + host = os.environ.get("HOST", "127.0.0.1") + port = int(os.environ.get("PORT", "8000")) server = ThreadingHTTPServer((host, port), Handler) print(f"Days Without Strife planner UI: http://{host}:{port}") try: