Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +92 -88
Dockerfile
CHANGED
|
@@ -4,12 +4,18 @@ FROM python:3.10-slim
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# 1. Install System Dependencies
|
| 8 |
-
# '
|
| 9 |
-
RUN apt-get update && apt-get install -y
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
RUN pip install --no-cache-dir \
|
| 14 |
torch \
|
| 15 |
flask \
|
|
@@ -20,49 +26,27 @@ RUN pip install --no-cache-dir \
|
|
| 20 |
safetensors \
|
| 21 |
scipy
|
| 22 |
|
| 23 |
-
#
|
| 24 |
RUN useradd -m -u 1000 user
|
| 25 |
USER user
|
| 26 |
ENV HOME=/home/user \
|
| 27 |
PATH=/home/user/.local/bin:$PATH
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
# We use 'COPY <<'EOF' app.py' to preserve all special characters, quotes, and backslashes exactly.
|
| 31 |
COPY --chown=user <<'EOF' app.py
|
| 32 |
import sys
|
| 33 |
import os
|
| 34 |
-
import subprocess
|
| 35 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# ============================================================================
|
| 38 |
-
# 1.
|
| 39 |
-
# ============================================================================
|
| 40 |
-
def ensure_portable_env():
|
| 41 |
-
"""
|
| 42 |
-
Checks if a local 'py312' folder exists.
|
| 43 |
-
If yes, and we aren't running from it, RESTART script using that Python.
|
| 44 |
-
"""
|
| 45 |
-
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 46 |
-
portable_python = os.path.join(base_dir, "py312", "python.exe")
|
| 47 |
-
|
| 48 |
-
if os.path.exists(portable_python):
|
| 49 |
-
current_exe = os.path.normpath(sys.executable).lower()
|
| 50 |
-
target_exe = os.path.normpath(portable_python).lower()
|
| 51 |
-
|
| 52 |
-
if current_exe != target_exe:
|
| 53 |
-
print(f"[*] SWITCHING TO PORTABLE KERNEL: {portable_python}")
|
| 54 |
-
args = [portable_python, __file__] + sys.argv[1:]
|
| 55 |
-
subprocess.call(args)
|
| 56 |
-
sys.exit(0)
|
| 57 |
-
else:
|
| 58 |
-
print(f"[*] Portable 'py312' not found. Using system Python: {sys.executable}")
|
| 59 |
-
|
| 60 |
-
ensure_portable_env()
|
| 61 |
-
|
| 62 |
-
# ============================================================================
|
| 63 |
-
# 2. DEPENDENCY CHECK & IMPORTS
|
| 64 |
# ============================================================================
|
| 65 |
-
print(f"[*] NeuralOS Monolith
|
| 66 |
|
| 67 |
try:
|
| 68 |
import torch
|
|
@@ -75,7 +59,7 @@ except ImportError as e:
|
|
| 75 |
sys.exit(1)
|
| 76 |
|
| 77 |
# ============================================================================
|
| 78 |
-
#
|
| 79 |
# ============================================================================
|
| 80 |
|
| 81 |
HTML_TEMPLATE = """
|
|
@@ -83,6 +67,7 @@ HTML_TEMPLATE = """
|
|
| 83 |
<html lang="en">
|
| 84 |
<head>
|
| 85 |
<meta charset="UTF-8">
|
|
|
|
| 86 |
<title>NeuralOS | Monolith</title>
|
| 87 |
<style>
|
| 88 |
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
|
|
@@ -90,29 +75,43 @@ HTML_TEMPLATE = """
|
|
| 90 |
body {
|
| 91 |
background: #050505;
|
| 92 |
margin: 0;
|
|
|
|
|
|
|
|
|
|
| 93 |
overflow: hidden;
|
| 94 |
display: flex;
|
| 95 |
justify-content: center;
|
| 96 |
align-items: center;
|
| 97 |
-
height: 100vh;
|
| 98 |
font-family: 'VT323', monospace;
|
| 99 |
}
|
| 100 |
|
|
|
|
| 101 |
.monitor-case {
|
| 102 |
background: #1a1a1a;
|
| 103 |
-
padding:
|
| 104 |
-
border-radius:
|
| 105 |
-
box-shadow: 0 0 0
|
| 106 |
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
.screen-container {
|
| 110 |
-
width:
|
| 111 |
-
height:
|
| 112 |
position: relative;
|
| 113 |
background: #000;
|
| 114 |
overflow: hidden;
|
| 115 |
-
border-radius:
|
|
|
|
| 116 |
}
|
| 117 |
|
| 118 |
.crt-overlay {
|
|
@@ -138,43 +137,47 @@ HTML_TEMPLATE = """
|
|
| 138 |
|
| 139 |
@keyframes scanline { 0% { bottom: 100%; } 100% { bottom: -100px; } }
|
| 140 |
|
|
|
|
| 141 |
#display {
|
| 142 |
width: 100%;
|
| 143 |
height: 100%;
|
| 144 |
object-fit: contain;
|
| 145 |
-
image-rendering: pixelated;
|
|
|
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
.controls {
|
| 149 |
-
position: absolute;
|
| 150 |
-
bottom: -60px;
|
| 151 |
-
right: 20px;
|
| 152 |
display: flex;
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
}
|
| 155 |
|
| 156 |
.pwr-btn {
|
| 157 |
background: #333;
|
| 158 |
color: #0f0;
|
| 159 |
-
border:
|
| 160 |
-
padding:
|
| 161 |
font-family: 'VT323';
|
|
|
|
| 162 |
cursor: pointer;
|
| 163 |
text-transform: uppercase;
|
| 164 |
-
box-shadow: 0
|
| 165 |
}
|
| 166 |
-
.pwr-btn:active { transform: translateY(
|
| 167 |
|
| 168 |
.led {
|
| 169 |
-
width:
|
| 170 |
-
height:
|
| 171 |
border-radius: 50%;
|
| 172 |
background: #111;
|
| 173 |
-
|
| 174 |
-
box-shadow: 0 0 2px #000;
|
| 175 |
}
|
| 176 |
-
.led.on { background: #0f0; box-shadow: 0 0
|
| 177 |
-
.led.busy { background: #f00; box-shadow: 0 0
|
| 178 |
@keyframes blink { 0% { opacity: 0.5; } 100% { opacity: 1; } }
|
| 179 |
</style>
|
| 180 |
</head>
|
|
@@ -183,12 +186,12 @@ HTML_TEMPLATE = """
|
|
| 183 |
<div class="screen-container">
|
| 184 |
<div class="crt-overlay"></div>
|
| 185 |
<div class="scanline"></div>
|
| 186 |
-
<img id="display" src="" alt="AWAITING
|
| 187 |
</div>
|
| 188 |
<div class="controls">
|
| 189 |
<div class="led on"></div>
|
| 190 |
<div id="hdd-led" class="led"></div>
|
| 191 |
-
<button class="pwr-btn" onclick="location.reload()">
|
| 192 |
</div>
|
| 193 |
</div>
|
| 194 |
<script>
|
|
@@ -214,7 +217,9 @@ HTML_TEMPLATE = """
|
|
| 214 |
|
| 215 |
display.addEventListener('mousedown', (e) => {
|
| 216 |
if (!ws) return;
|
|
|
|
| 217 |
const rect = display.getBoundingClientRect();
|
|
|
|
| 218 |
const x = Math.floor(((e.clientX - rect.left) / rect.width) * 128);
|
| 219 |
const y = Math.floor(((e.clientY - rect.top) / rect.height) * 128);
|
| 220 |
ws.send(JSON.stringify({ type: 'click', x: x, y: y }));
|
|
@@ -235,15 +240,9 @@ HTML_TEMPLATE = """
|
|
| 235 |
"""
|
| 236 |
|
| 237 |
# ============================================================================
|
| 238 |
-
#
|
| 239 |
# ============================================================================
|
| 240 |
|
| 241 |
-
from dataclasses import dataclass, field
|
| 242 |
-
from typing import Dict, List
|
| 243 |
-
import io
|
| 244 |
-
import json
|
| 245 |
-
import base64
|
| 246 |
-
|
| 247 |
DRIVERS = {
|
| 248 |
"TITLE_BAR": torch.zeros((1, 4, 4, 32), dtype=torch.float16),
|
| 249 |
"CLOSE_BTN": torch.zeros((1, 4, 4, 4), dtype=torch.float16),
|
|
@@ -325,11 +324,11 @@ class OSKernel:
|
|
| 325 |
|
| 326 |
buf = []
|
| 327 |
if app_type == "cmd":
|
| 328 |
-
buf = ["NEURAL OS [
|
| 329 |
elif app_type == "notepad":
|
| 330 |
buf = ["_"]
|
| 331 |
elif app_type == "doom":
|
| 332 |
-
buf = ["[INIT] LOADING
|
| 333 |
|
| 334 |
self.processes[pid] = Process(
|
| 335 |
pid, app.name, app_type, (x, y), app.default_size,
|
|
@@ -401,19 +400,24 @@ class OSKernel:
|
|
| 401 |
return out
|
| 402 |
|
| 403 |
# ============================================================================
|
| 404 |
-
#
|
| 405 |
# ============================================================================
|
| 406 |
|
| 407 |
app = Flask(__name__)
|
| 408 |
sock = Sock(app)
|
| 409 |
pipe = None
|
| 410 |
kernel = OSKernel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
|
| 412 |
def init_ai():
|
| 413 |
global pipe
|
| 414 |
print("[*] Loading Neural Graphics Pipeline...")
|
| 415 |
|
| 416 |
-
# AUTO-DETECT DEVICE
|
| 417 |
if torch.cuda.is_available():
|
| 418 |
device = "cuda"
|
| 419 |
dtype = torch.float16
|
|
@@ -455,30 +459,35 @@ def render_frame(k_obj):
|
|
| 455 |
else:
|
| 456 |
pil_img = Image.new('RGB', (128, 128), (0,0,0))
|
| 457 |
|
|
|
|
| 458 |
pil_img = pil_img.resize((1024, 1024), resample=Image.NEAREST)
|
| 459 |
draw = ImageDraw.Draw(pil_img)
|
| 460 |
-
font = ImageFont.load_default()
|
| 461 |
|
| 462 |
if k_obj.system_state == "BOOT":
|
| 463 |
y = 50
|
| 464 |
for log in k_obj.boot_log:
|
| 465 |
-
draw.text((50, y), log, fill=(0, 255, 0), font=
|
| 466 |
-
y +=
|
| 467 |
|
| 468 |
scale = 8
|
| 469 |
for p in k_obj.processes.values():
|
| 470 |
wx, wy = p.position
|
| 471 |
-
cx = (wx * scale) +
|
| 472 |
-
cy = (wy * scale) +
|
| 473 |
-
|
|
|
|
|
|
|
|
|
|
| 474 |
if p.text_buffer:
|
| 475 |
-
|
|
|
|
|
|
|
| 476 |
col = (0, 255, 0) if p.app_type == "cmd" else (0,0,0)
|
| 477 |
if p.app_type == "doom": col = (255, 50, 50)
|
| 478 |
-
draw.text((cx, cy + (i*
|
| 479 |
|
| 480 |
buf = io.BytesIO()
|
| 481 |
-
pil_img.save(buf, format="JPEG", quality=
|
| 482 |
return base64.b64encode(buf.getvalue()).decode()
|
| 483 |
|
| 484 |
@app.route('/')
|
|
@@ -546,14 +555,9 @@ def websocket_kernel(ws):
|
|
| 546 |
break
|
| 547 |
|
| 548 |
if __name__ == "__main__":
|
| 549 |
-
print("="*50)
|
| 550 |
-
print(" NEURAL OS MONOLITH v9.2")
|
| 551 |
-
print(" http://0.0.0.0:7860")
|
| 552 |
-
print("="*50)
|
| 553 |
-
# Updated to port 7860 for Hugging Face
|
| 554 |
app.run(host="0.0.0.0", port=7860, threaded=True)
|
| 555 |
EOF
|
| 556 |
|
| 557 |
-
#
|
| 558 |
EXPOSE 7860
|
| 559 |
CMD ["python", "app.py"]
|
|
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# 1. Install System Dependencies & Fonts
|
| 8 |
+
# We add 'curl' to download the font and 'git' for diffusers compatibility.
|
| 9 |
+
RUN apt-get update && apt-get install -y \
|
| 10 |
+
git \
|
| 11 |
+
curl \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# 2. Download Retro Font (VT323) for Python PIL
|
| 15 |
+
# This fixes the "text too small" issue by allowing us to load a specific large font size.
|
| 16 |
+
RUN curl -L -o /app/VT323.ttf https://github.com/google/fonts/raw/main/ofl/vt323/VT323-Regular.ttf
|
| 17 |
+
|
| 18 |
+
# 3. Install Python Dependencies
|
| 19 |
RUN pip install --no-cache-dir \
|
| 20 |
torch \
|
| 21 |
flask \
|
|
|
|
| 26 |
safetensors \
|
| 27 |
scipy
|
| 28 |
|
| 29 |
+
# 4. Create a non-root user (Required for Hugging Face Spaces)
|
| 30 |
RUN useradd -m -u 1000 user
|
| 31 |
USER user
|
| 32 |
ENV HOME=/home/user \
|
| 33 |
PATH=/home/user/.local/bin:$PATH
|
| 34 |
|
| 35 |
+
# 5. Write the Monolith Application to disk
|
|
|
|
| 36 |
COPY --chown=user <<'EOF' app.py
|
| 37 |
import sys
|
| 38 |
import os
|
|
|
|
| 39 |
import time
|
| 40 |
+
import io
|
| 41 |
+
import json
|
| 42 |
+
import base64
|
| 43 |
+
from dataclasses import dataclass, field
|
| 44 |
+
from typing import Dict, List
|
| 45 |
|
| 46 |
# ============================================================================
|
| 47 |
+
# 1. DEPENDENCY CHECK & IMPORTS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
# ============================================================================
|
| 49 |
+
print(f"[*] NeuralOS Monolith v9.3 OPTIMIZED (Running in: {sys.executable})")
|
| 50 |
|
| 51 |
try:
|
| 52 |
import torch
|
|
|
|
| 59 |
sys.exit(1)
|
| 60 |
|
| 61 |
# ============================================================================
|
| 62 |
+
# 2. OPTIMIZED EMBEDDED GUI (Responsive & High-DPI Ready)
|
| 63 |
# ============================================================================
|
| 64 |
|
| 65 |
HTML_TEMPLATE = """
|
|
|
|
| 67 |
<html lang="en">
|
| 68 |
<head>
|
| 69 |
<meta charset="UTF-8">
|
| 70 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 71 |
<title>NeuralOS | Monolith</title>
|
| 72 |
<style>
|
| 73 |
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
|
|
|
|
| 75 |
body {
|
| 76 |
background: #050505;
|
| 77 |
margin: 0;
|
| 78 |
+
padding: 0;
|
| 79 |
+
width: 100vw;
|
| 80 |
+
height: 100vh;
|
| 81 |
overflow: hidden;
|
| 82 |
display: flex;
|
| 83 |
justify-content: center;
|
| 84 |
align-items: center;
|
|
|
|
| 85 |
font-family: 'VT323', monospace;
|
| 86 |
}
|
| 87 |
|
| 88 |
+
/* Responsive Monitor Case */
|
| 89 |
.monitor-case {
|
| 90 |
background: #1a1a1a;
|
| 91 |
+
padding: 1.5vmin; /* Responsive padding */
|
| 92 |
+
border-radius: 1vmin;
|
| 93 |
+
box-shadow: 0 0 0 0.4vmin #222, 0 0 4vmin rgba(0,0,0,0.8), inset 0 0 2vmin rgba(0,0,0,0.5);
|
| 94 |
position: relative;
|
| 95 |
+
|
| 96 |
+
/* Responsive Sizing Logic */
|
| 97 |
+
width: auto;
|
| 98 |
+
height: auto;
|
| 99 |
+
max-width: 95vw;
|
| 100 |
+
max-height: 90vh;
|
| 101 |
+
aspect-ratio: 1 / 1; /* Force Square Aspect Ratio */
|
| 102 |
+
|
| 103 |
+
display: flex;
|
| 104 |
+
flex-direction: column;
|
| 105 |
}
|
| 106 |
|
| 107 |
.screen-container {
|
| 108 |
+
width: 100%;
|
| 109 |
+
height: 100%;
|
| 110 |
position: relative;
|
| 111 |
background: #000;
|
| 112 |
overflow: hidden;
|
| 113 |
+
border-radius: 0.5vmin;
|
| 114 |
+
flex-grow: 1;
|
| 115 |
}
|
| 116 |
|
| 117 |
.crt-overlay {
|
|
|
|
| 137 |
|
| 138 |
@keyframes scanline { 0% { bottom: 100%; } 100% { bottom: -100px; } }
|
| 139 |
|
| 140 |
+
/* KEY FIX: Ensure pixel art stays sharp when scaled down */
|
| 141 |
#display {
|
| 142 |
width: 100%;
|
| 143 |
height: 100%;
|
| 144 |
object-fit: contain;
|
| 145 |
+
image-rendering: pixelated;
|
| 146 |
+
image-rendering: crisp-edges;
|
| 147 |
+
display: block;
|
| 148 |
}
|
| 149 |
|
| 150 |
.controls {
|
|
|
|
|
|
|
|
|
|
| 151 |
display: flex;
|
| 152 |
+
justify-content: flex-end;
|
| 153 |
+
align-items: center;
|
| 154 |
+
gap: 1vmin;
|
| 155 |
+
padding-top: 1vmin;
|
| 156 |
+
height: 4vmin;
|
| 157 |
}
|
| 158 |
|
| 159 |
.pwr-btn {
|
| 160 |
background: #333;
|
| 161 |
color: #0f0;
|
| 162 |
+
border: 0.2vmin solid #222;
|
| 163 |
+
padding: 0.5vmin 1.5vmin;
|
| 164 |
font-family: 'VT323';
|
| 165 |
+
font-size: 2vmin;
|
| 166 |
cursor: pointer;
|
| 167 |
text-transform: uppercase;
|
| 168 |
+
box-shadow: 0 0.4vmin 0 #111;
|
| 169 |
}
|
| 170 |
+
.pwr-btn:active { transform: translateY(0.4vmin); box-shadow: none; }
|
| 171 |
|
| 172 |
.led {
|
| 173 |
+
width: 1.5vmin;
|
| 174 |
+
height: 1.5vmin;
|
| 175 |
border-radius: 50%;
|
| 176 |
background: #111;
|
| 177 |
+
box-shadow: 0 0 0.2vmin #000;
|
|
|
|
| 178 |
}
|
| 179 |
+
.led.on { background: #0f0; box-shadow: 0 0 0.5vmin #0f0; }
|
| 180 |
+
.led.busy { background: #f00; box-shadow: 0 0 0.5vmin #f00; animation: blink 0.1s infinite; }
|
| 181 |
@keyframes blink { 0% { opacity: 0.5; } 100% { opacity: 1; } }
|
| 182 |
</style>
|
| 183 |
</head>
|
|
|
|
| 186 |
<div class="screen-container">
|
| 187 |
<div class="crt-overlay"></div>
|
| 188 |
<div class="scanline"></div>
|
| 189 |
+
<img id="display" src="" alt="AWAITING SIGNAL..." />
|
| 190 |
</div>
|
| 191 |
<div class="controls">
|
| 192 |
<div class="led on"></div>
|
| 193 |
<div id="hdd-led" class="led"></div>
|
| 194 |
+
<button class="pwr-btn" onclick="location.reload()">RESET</button>
|
| 195 |
</div>
|
| 196 |
</div>
|
| 197 |
<script>
|
|
|
|
| 217 |
|
| 218 |
display.addEventListener('mousedown', (e) => {
|
| 219 |
if (!ws) return;
|
| 220 |
+
// Responsive coordinate calculation
|
| 221 |
const rect = display.getBoundingClientRect();
|
| 222 |
+
// Map the clicked position (0 to rect.width) to internal resolution (0 to 128)
|
| 223 |
const x = Math.floor(((e.clientX - rect.left) / rect.width) * 128);
|
| 224 |
const y = Math.floor(((e.clientY - rect.top) / rect.height) * 128);
|
| 225 |
ws.send(JSON.stringify({ type: 'click', x: x, y: y }));
|
|
|
|
| 240 |
"""
|
| 241 |
|
| 242 |
# ============================================================================
|
| 243 |
+
# 3. KERNEL & HARDWARE
|
| 244 |
# ============================================================================
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
DRIVERS = {
|
| 247 |
"TITLE_BAR": torch.zeros((1, 4, 4, 32), dtype=torch.float16),
|
| 248 |
"CLOSE_BTN": torch.zeros((1, 4, 4, 4), dtype=torch.float16),
|
|
|
|
| 324 |
|
| 325 |
buf = []
|
| 326 |
if app_type == "cmd":
|
| 327 |
+
buf = ["NEURAL OS [v9.3]", "(C) Monolith", "", f"{self.current_dir}>"]
|
| 328 |
elif app_type == "notepad":
|
| 329 |
buf = ["_"]
|
| 330 |
elif app_type == "doom":
|
| 331 |
+
buf = ["[INIT] LOADING...", "[INIT] CONNECTING..."]
|
| 332 |
|
| 333 |
self.processes[pid] = Process(
|
| 334 |
pid, app.name, app_type, (x, y), app.default_size,
|
|
|
|
| 400 |
return out
|
| 401 |
|
| 402 |
# ============================================================================
|
| 403 |
+
# 4. SERVER & RENDERER
|
| 404 |
# ============================================================================
|
| 405 |
|
| 406 |
app = Flask(__name__)
|
| 407 |
sock = Sock(app)
|
| 408 |
pipe = None
|
| 409 |
kernel = OSKernel()
|
| 410 |
+
# Load the font downloaded in Dockerfile. Size 32 is large enough for 1024px render.
|
| 411 |
+
try:
|
| 412 |
+
SYSTEM_FONT = ImageFont.truetype("/app/VT323.ttf", 32)
|
| 413 |
+
except Exception:
|
| 414 |
+
print("[!] Font load failed, using default")
|
| 415 |
+
SYSTEM_FONT = ImageFont.load_default()
|
| 416 |
|
| 417 |
def init_ai():
|
| 418 |
global pipe
|
| 419 |
print("[*] Loading Neural Graphics Pipeline...")
|
| 420 |
|
|
|
|
| 421 |
if torch.cuda.is_available():
|
| 422 |
device = "cuda"
|
| 423 |
dtype = torch.float16
|
|
|
|
| 459 |
else:
|
| 460 |
pil_img = Image.new('RGB', (128, 128), (0,0,0))
|
| 461 |
|
| 462 |
+
# Keep 1024px render for high detail, but Font Size 32 makes it readable
|
| 463 |
pil_img = pil_img.resize((1024, 1024), resample=Image.NEAREST)
|
| 464 |
draw = ImageDraw.Draw(pil_img)
|
|
|
|
| 465 |
|
| 466 |
if k_obj.system_state == "BOOT":
|
| 467 |
y = 50
|
| 468 |
for log in k_obj.boot_log:
|
| 469 |
+
draw.text((50, y), log, fill=(0, 255, 0), font=SYSTEM_FONT)
|
| 470 |
+
y += 35 # Increased spacing for larger font
|
| 471 |
|
| 472 |
scale = 8
|
| 473 |
for p in k_obj.processes.values():
|
| 474 |
wx, wy = p.position
|
| 475 |
+
cx = (wx * scale) + 16 # Padding adjusted for scale
|
| 476 |
+
cy = (wy * scale) + 40
|
| 477 |
+
|
| 478 |
+
# Draw Title
|
| 479 |
+
draw.text(((wx*scale)+10, (wy*scale)+5), p.name, fill=(255,255,255), font=SYSTEM_FONT)
|
| 480 |
+
|
| 481 |
if p.text_buffer:
|
| 482 |
+
# Show fewer lines because font is larger, ensuring it fits in window
|
| 483 |
+
lines_to_show = p.text_buffer[-12:]
|
| 484 |
+
for i, line in enumerate(lines_to_show):
|
| 485 |
col = (0, 255, 0) if p.app_type == "cmd" else (0,0,0)
|
| 486 |
if p.app_type == "doom": col = (255, 50, 50)
|
| 487 |
+
draw.text((cx, cy + (i*30)), line, fill=col, font=SYSTEM_FONT)
|
| 488 |
|
| 489 |
buf = io.BytesIO()
|
| 490 |
+
pil_img.save(buf, format="JPEG", quality=80)
|
| 491 |
return base64.b64encode(buf.getvalue()).decode()
|
| 492 |
|
| 493 |
@app.route('/')
|
|
|
|
| 555 |
break
|
| 556 |
|
| 557 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
app.run(host="0.0.0.0", port=7860, threaded=True)
|
| 559 |
EOF
|
| 560 |
|
| 561 |
+
# 6. Launch the Monolith
|
| 562 |
EXPOSE 7860
|
| 563 |
CMD ["python", "app.py"]
|