prole/installer/workstation.py
chrisfu aad4c9c919 installer: switch workstation build to Docker, drop Vagrant
- Remove Vagrant from dependency checks and UI; use Docker for workstation build.\n- Add WORKSTATION_VERSION ARG + OCI version label in workstation/Dockerfile; tag image as prole-workstation:<version>.\n- Add installer.workstation helpers: parse version, compose canonical docker build (auto platform flags on Apple Silicon).\n- Refactor install.py Workstation page to display/execute docker build; write logs to logs/workstation-docker-<ts>.log; update summary links.\n- Update Deploy page copy: "Build workstation Docker image".\n- Centralize footer buttons styling/layout with installer.screen.create_nav_footer and use it from install.py.\n- Update installer package docs to describe Docker-based workstation helpers.
2025-12-03 22:55:21 -08:00

50 lines
1.6 KiB
Python

"""
Workstation (Docker) build helpers for the Prole installer (root-level).
Compose a deterministic Docker build command and derive the image tag version
from the workstation/Dockerfile.
"""
from __future__ import annotations
from pathlib import Path
import re
from . import config as cfg
def get_workstation_version(project_root: Path) -> str:
"""Parse the workstation Dockerfile for a version.
Looks for one of the following (first match wins):
- ARG WORKSTATION_VERSION=1.2.3
- LABEL org.opencontainers.image.version="1.2.3"
Falls back to "0.1.0" if none found.
"""
ws = Path(project_root) / "workstation" / "Dockerfile"
default_ver = "0.1.0"
try:
text = ws.read_text(encoding="utf-8")
except Exception:
return default_ver
# ARG pattern
m = re.search(r"^\s*ARG\s+WORKSTATION_VERSION\s*=\s*([\w\.-]+)\s*$", text, re.MULTILINE)
if m:
return m.group(1)
# LABEL pattern
m2 = re.search(r"org\.opencontainers\.image\.version\s*=\s*\"?([\w\.-]+)\"?", text)
if m2:
return m2.group(1)
return default_ver
def get_docker_build_command(project_root: Path) -> str:
"""Return the canonical Docker build command for the workstation image.
docker build -t prole-workstation:<version> .
Includes platform flags for Apple Silicon when appropriate.
"""
ws = Path(project_root) / "workstation"
version = get_workstation_version(project_root)
platform_args = cfg.get_docker_build_platform_args()
plat = (" ".join(platform_args) + " ") if platform_args else ""
return f"cd \"{ws}\" && docker build {plat}-t prole-workstation:{version} ."