docker
This commit is contained in:
parent
751a0e2525
commit
df0d42b2ec
3 changed files with 17 additions and 20 deletions
22
Dockerfile
22
Dockerfile
|
|
@ -5,19 +5,19 @@ WORKDIR /app
|
||||||
# Install uv
|
# Install uv
|
||||||
RUN pip install --no-cache-dir uv
|
RUN pip install --no-cache-dir uv
|
||||||
|
|
||||||
# Copy project files
|
# Install dependencies first (cached unless the lockfile changes)
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
|
RUN uv sync --frozen --no-install-project
|
||||||
# Install dependencies with uv
|
|
||||||
RUN uv sync --no-editable
|
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY solve.py web_solve.py ./
|
COPY solve.py main.py index.html ./
|
||||||
COPY templates/ templates/
|
|
||||||
|
|
||||||
# Set environment variables
|
# Bind to all interfaces so the server is reachable outside the container
|
||||||
ENV FLASK_APP=web_solve.py
|
ENV HOST=0.0.0.0 \
|
||||||
ENV PYTHONUNBUFFERED=1
|
PORT=8000 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Run Flask app
|
EXPOSE 8000
|
||||||
CMD ["uv", "run", "python", "web_solve.py"]
|
|
||||||
|
# Run the stdlib HTTP server
|
||||||
|
CMD ["uv", "run", "--frozen", "python", "main.py"]
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "5555:5000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=development
|
- HOST=0.0.0.0
|
||||||
- FLASK_DEBUG=1
|
- PORT=8000
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
command: uv run python web_solve.py
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
||||||
4
main.py
4
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
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -58,7 +59,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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)
|
server = ThreadingHTTPServer((host, port), Handler)
|
||||||
print(f"Days Without Strife planner UI: http://{host}:{port}")
|
print(f"Days Without Strife planner UI: http://{host}:{port}")
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue