forked from linkong/planet
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e65267fe21 | |||
| ae982e51cd |
@@ -2,10 +2,14 @@
|
||||
|
||||
ARG PYTHON_IMAGE=python:3.14-slim
|
||||
ARG UV_IMAGE=ghcr.io/astral-sh/uv:latest
|
||||
ARG AI_PROVIDER_BUILD_FINGERPRINT=unknown
|
||||
|
||||
FROM ${UV_IMAGE} AS uv
|
||||
FROM ${PYTHON_IMAGE}
|
||||
|
||||
ARG AI_PROVIDER_BUILD_FINGERPRINT
|
||||
LABEL planet.aiprovider.build-fingerprint="${AI_PROVIDER_BUILD_FINGERPRINT}"
|
||||
|
||||
COPY --from=uv /uv /uvx /bin/
|
||||
|
||||
WORKDIR /app
|
||||
@@ -15,12 +19,15 @@ ENV PYTHONUNBUFFERED=1
|
||||
ENV UV_COMPILE_BYTECODE=1
|
||||
ENV UV_LINK_MODE=copy
|
||||
|
||||
RUN mkdir -p /root/.config/uv
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY pyproject.toml uv.lock /app/
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=secret,id=planet_uv_config,target=/root/.config/uv/uv.toml,required=false \
|
||||
uv sync --frozen --no-dev
|
||||
|
||||
COPY aiprovider /app/aiprovider
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
ARG PYTHON_IMAGE=python:3.14-slim
|
||||
ARG UV_IMAGE=ghcr.io/astral-sh/uv:latest
|
||||
|
||||
@@ -14,12 +16,16 @@ ENV UV_COMPILE_BYTECODE=1
|
||||
ENV UV_LINK_MODE=copy
|
||||
ENV PYTHONPATH=/app/backend
|
||||
|
||||
RUN mkdir -p /root/.config/uv
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY pyproject.toml uv.lock /app/
|
||||
RUN uv sync --frozen --no-dev
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=secret,id=planet_uv_config,target=/root/.config/uv/uv.toml,required=false \
|
||||
uv sync --frozen --no-dev
|
||||
|
||||
COPY backend /app/backend
|
||||
COPY VERSION /app/VERSION
|
||||
|
||||
@@ -15,12 +15,16 @@ services:
|
||||
retries: 10
|
||||
|
||||
aiprovider:
|
||||
image: ${AI_PROVIDER_IMAGE_NAME:-planet-aiprovider:latest}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: aiprovider/Dockerfile
|
||||
args:
|
||||
PYTHON_IMAGE: ${PYTHON_IMAGE:-python:3.14-slim}
|
||||
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:latest}
|
||||
AI_PROVIDER_BUILD_FINGERPRINT: ${AI_PROVIDER_BUILD_FINGERPRINT:-unknown}
|
||||
secrets:
|
||||
- planet_uv_config
|
||||
container_name: planet_aiprovider
|
||||
ports:
|
||||
- "8010:8010"
|
||||
@@ -43,3 +47,7 @@ services:
|
||||
|
||||
volumes:
|
||||
ollama_data:
|
||||
|
||||
secrets:
|
||||
planet_uv_config:
|
||||
file: ${PLANET_UV_CONFIG_FILE:-/dev/null}
|
||||
|
||||
@@ -2,12 +2,16 @@ version: '3.8'
|
||||
|
||||
services:
|
||||
aiprovider:
|
||||
image: ${AI_PROVIDER_IMAGE_NAME:-planet-aiprovider:latest}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: aiprovider/Dockerfile
|
||||
args:
|
||||
PYTHON_IMAGE: ${PYTHON_IMAGE:-python:3.14-slim}
|
||||
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:latest}
|
||||
AI_PROVIDER_BUILD_FINGERPRINT: ${AI_PROVIDER_BUILD_FINGERPRINT:-unknown}
|
||||
secrets:
|
||||
- planet_uv_config
|
||||
env_file:
|
||||
- ./aiprovider/.env
|
||||
- ${PLANET_AI_PROVIDER_RUNTIME_ENV_FILE:-./aiprovider/.env}
|
||||
@@ -43,3 +47,7 @@ services:
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
secrets:
|
||||
planet_uv_config:
|
||||
file: ${PLANET_UV_CONFIG_FILE:-/dev/null}
|
||||
|
||||
@@ -2,12 +2,16 @@ version: '3.8'
|
||||
|
||||
services:
|
||||
aiprovider:
|
||||
image: ${AI_PROVIDER_IMAGE_NAME:-planet-aiprovider:latest}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: aiprovider/Dockerfile
|
||||
args:
|
||||
PYTHON_IMAGE: ${PYTHON_IMAGE:-python:3.14-slim}
|
||||
UV_IMAGE: ${UV_IMAGE:-ghcr.io/astral-sh/uv:latest}
|
||||
AI_PROVIDER_BUILD_FINGERPRINT: ${AI_PROVIDER_BUILD_FINGERPRINT:-unknown}
|
||||
secrets:
|
||||
- planet_uv_config
|
||||
env_file:
|
||||
- ./aiprovider/.env
|
||||
- ${PLANET_AI_PROVIDER_RUNTIME_ENV_FILE:-./aiprovider/.env}
|
||||
@@ -53,3 +57,7 @@ services:
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
secrets:
|
||||
planet_uv_config:
|
||||
file: ${PLANET_UV_CONFIG_FILE:-/dev/null}
|
||||
|
||||
@@ -8,6 +8,38 @@ This project follows the repository versioning rule:
|
||||
- `improvement` -> `+0.0.1`(bugfix + 小功能混合)
|
||||
- `bugfix` -> `+0.0.1`
|
||||
|
||||
## [0.65.2] — 2026-05-22
|
||||
|
||||
Released: 2026-05-22
|
||||
|
||||
### Highlights
|
||||
- Stabilize AI Provider rebuild detection so unchanged source no longer rebuilds just because file timestamps or local cache state changed.
|
||||
- Keep `uv.lock` on the official registry while still allowing local and Docker builds to use the user's `uv.toml`.
|
||||
- Prevent local startup and bootstrap commands from rewriting `uv.lock` when a user-level mirror is configured.
|
||||
|
||||
### Added / Fixed / Improved
|
||||
- AI Provider fingerprints now use content hashes, base image inputs, dependency metadata, and an image label instead of file mtimes.
|
||||
- `planet.sh` and `scripts/bootstrap-dev.sh` now use `uv sync --frozen`, and backend startup uses `uv run --frozen`.
|
||||
- Docker Compose passes the AI Provider fingerprint into the image build so future starts can inspect the image label directly.
|
||||
|
||||
---
|
||||
|
||||
## [0.65.1] — 2026-05-22
|
||||
|
||||
Released: 2026-05-22
|
||||
|
||||
### Highlights
|
||||
- 修复 `planet.sh` 与 Docker Compose 对 AI Provider 镜像名不一致导致的重复构建问题。
|
||||
- 让本地 `uv` 与 Docker build 统一使用用户机器上的 `uv.toml`,避免把镜像源写入 `uv.lock`。
|
||||
- 通过 BuildKit secret 向容器构建传入 uv 配置,保留用户源选择且不把配置写入镜像层。
|
||||
|
||||
### Added / Fixed / Improved
|
||||
- `planet.sh` 自动解析 `UV_CONFIG_FILE`、仓库 `uv.toml` 与用户级 `~/.config/uv/uv.toml`,并清理会覆盖配置的 `UV_INDEX_URL` 环境变量。
|
||||
- AI Provider 和后端 Dockerfile 在 `uv sync` 阶段挂载 uv 配置 secret,并复用 BuildKit uv cache。
|
||||
- Docker Compose 三套配置统一声明 `planet-aiprovider:latest` 镜像名和 `planet_uv_config` build secret。
|
||||
|
||||
---
|
||||
|
||||
## [0.65.0] — 2026-05-21
|
||||
|
||||
Released: 2026-05-21
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
## Current Version
|
||||
|
||||
- `main` 当前主线历史推导到:`0.16.5`
|
||||
- `dev` 当前开发分支历史推导到:`0.65.0`
|
||||
- `dev` 当前开发分支历史推导到:`0.65.2`
|
||||
|
||||
## Timeline
|
||||
|
||||
| Version | Type | Branch | Commit | Summary |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `0.65.2` | bugfix | `dev` | `pending` | AI Provider 镜像重建判定改为内容 fingerprint 与镜像 label,启动链路改用 frozen uv,避免用户级镜像源污染 `uv.lock`,并加入 Windows 一键启动脚本 |
|
||||
| `0.65.1` | bugfix | `dev` | `pending` | 统一 `planet.sh` 与 Compose 的 AI Provider 镜像名,并让本地和 Docker build 通过用户级 `uv.toml` 共享 uv 源配置,避免镜像源污染 `uv.lock` |
|
||||
| `0.65.0` | feature | `dev` | `pending` | Admin Next 数据源触发入口收敛为“触发全部/触发已选 N”,队列改为右上角浮层按钮,并强化 `planet.sh destroy` 的 OOBE 数据清理 |
|
||||
| `0.64.0` | feature | `dev` | `pending` | Earth 新增后端状态驱动 OOBE 与 About 配置,Admin Next 数据源页新增采集队列,补齐深色主题滑块和用户/技术文档 |
|
||||
| `0.63.1` | bugfix | `dev` | `pending` | 补上被 `lib/` ignore 规则漏提交的 Admin Next utility module,修复新设备初始化后 AdminNextRoutes 动态导入 500 |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "planet-frontend",
|
||||
"version": "0.65.0",
|
||||
"version": "0.65.2",
|
||||
"private": true,
|
||||
"packageManager": "bun@1",
|
||||
"dependencies": {
|
||||
|
||||
18
planet.cmd
Normal file
18
planet.cmd
Normal file
@@ -0,0 +1,18 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
|
||||
net session >nul 2>&1
|
||||
if not "%errorlevel%"=="0" (
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$script = '%~f0'; $arg = '-NoExit -NoProfile -ExecutionPolicy Bypass -Command ""& { & ''' + $script + ''' --elevated }""'; if (Get-Command wt.exe -ErrorAction SilentlyContinue) { Start-Process wt.exe -Verb RunAs -ArgumentList @('powershell.exe', $arg) } else { Start-Process powershell.exe -Verb RunAs -ArgumentList $arg }"
|
||||
exit /b
|
||||
)
|
||||
|
||||
if /i "%~1"=="--elevated" shift
|
||||
|
||||
echo Starting Planet in WSL as Administrator...
|
||||
echo This window will stay inside WSL after startup. Close it manually when you are done.
|
||||
echo.
|
||||
|
||||
wsl.exe -d Ubuntu --cd /home/linkong/planet -- zsh -lic "./planet.sh restart --allow-lan; planet_exit=\$?; echo; if [ \$planet_exit -eq 0 ]; then echo 'Planet restart finished successfully.'; powershell.exe -NoProfile -Command 'Start-Process "http://localhost:3000/earth"'; else echo \"Planet restart failed with exit code \$planet_exit.\"; fi; echo; echo 'Staying in WSL. Close this terminal manually when you are done.'; exec zsh -l"
|
||||
|
||||
exit /b %errorlevel%
|
||||
85
planet.sh
85
planet.sh
@@ -125,9 +125,11 @@ MOTION_AGENT_PID_FILE="$PLANET_STATE_DIR/motion_agent.pid"
|
||||
MOTION_AGENT_LOG_FILE="$PLANET_STATE_DIR/motion_agent.log"
|
||||
AI_PROVIDER_BUILD_STAMP_FILE="$PLANET_CACHE_DIR/aiprovider_build.sha256"
|
||||
AI_PROVIDER_BUILD_LOG_FILE="$PLANET_STATE_DIR/aiprovider_build.log"
|
||||
AI_PROVIDER_IMAGE_NAME="${AI_PROVIDER_IMAGE_NAME:-planet_aiprovider:latest}"
|
||||
AI_PROVIDER_IMAGE_NAME="${AI_PROVIDER_IMAGE_NAME:-planet-aiprovider:latest}"
|
||||
AI_PROVIDER_CONTAINER_NAME="${AI_PROVIDER_CONTAINER_NAME:-planet_aiprovider}"
|
||||
PLANET_AI_PROVIDER_RUNTIME_ENV_FILE="${PLANET_AI_PROVIDER_RUNTIME_ENV_FILE:-$PLANET_STATE_DIR/aiprovider_runtime.env}"
|
||||
PLANET_EMPTY_UV_CONFIG_FILE="$PLANET_STATE_DIR/uv.empty.toml"
|
||||
PLANET_UV_CONFIG_FILE="${PLANET_UV_CONFIG_FILE:-}"
|
||||
AI_PROVIDER_RECREATE_REQUIRED=0
|
||||
START_RUN_ACTIVE=0
|
||||
START_RUN_COMPLETED=0
|
||||
@@ -171,6 +173,46 @@ ensure_local_runtime_bins_on_path() {
|
||||
|
||||
ensure_local_runtime_bins_on_path
|
||||
|
||||
resolve_uv_config_file() {
|
||||
local candidate
|
||||
|
||||
if [ -n "${UV_CONFIG_FILE:-}" ] && [ -f "$UV_CONFIG_FILE" ]; then
|
||||
printf "%s\n" "$UV_CONFIG_FILE"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"$SCRIPT_DIR/uv.toml" \
|
||||
"${XDG_CONFIG_HOME:-$HOME/.config}/uv/uv.toml" \
|
||||
"$HOME/.uv/uv.toml"; do
|
||||
if [ -f "$candidate" ]; then
|
||||
printf "%s\n" "$candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
prepare_uv_build_config() {
|
||||
local uv_config_file
|
||||
|
||||
uv_config_file="$(resolve_uv_config_file || true)"
|
||||
if [ -n "$uv_config_file" ]; then
|
||||
PLANET_UV_CONFIG_FILE="$uv_config_file"
|
||||
else
|
||||
: > "$PLANET_EMPTY_UV_CONFIG_FILE"
|
||||
PLANET_UV_CONFIG_FILE="$PLANET_EMPTY_UV_CONFIG_FILE"
|
||||
fi
|
||||
|
||||
UV_CONFIG_FILE="$PLANET_UV_CONFIG_FILE"
|
||||
unset UV_DEFAULT_INDEX UV_INDEX_URL UV_EXTRA_INDEX_URL
|
||||
export UV_CONFIG_FILE
|
||||
export PLANET_UV_CONFIG_FILE
|
||||
}
|
||||
|
||||
prepare_uv_build_config
|
||||
|
||||
# Shell / Docker helpers
|
||||
is_pid() {
|
||||
[[ "${1:-}" =~ ^[0-9]+$ ]] && [ "$1" -gt 0 ]
|
||||
@@ -1075,6 +1117,9 @@ compute_ai_provider_build_fingerprint() {
|
||||
(
|
||||
cd "$SCRIPT_DIR" || exit 1
|
||||
{
|
||||
printf "PYTHON_IMAGE=%s\n" "${PYTHON_IMAGE:-python:3.14-slim}"
|
||||
printf "UV_IMAGE=%s\n" "${UV_IMAGE:-ghcr.io/astral-sh/uv:latest}"
|
||||
sha256sum aiprovider/Dockerfile pyproject.toml uv.lock 2>/dev/null
|
||||
find aiprovider \
|
||||
-type f \
|
||||
! -path '*/__pycache__/*' \
|
||||
@@ -1083,8 +1128,7 @@ compute_ai_provider_build_fingerprint() {
|
||||
! -name '*.pyc' \
|
||||
! -name '*.pyo' \
|
||||
| LC_ALL=C sort \
|
||||
| xargs -r stat --format="%Y %s %n" 2>/dev/null
|
||||
sha256sum docker-compose.yml docker-compose.simple.yml 2>/dev/null
|
||||
| xargs -r sha256sum 2>/dev/null
|
||||
python3 "$SCRIPT_DIR/scripts/compute_aiprovider_dependency_fingerprint.py" 2>/dev/null
|
||||
}
|
||||
) | sha256sum | awk '{print $1}'
|
||||
@@ -1105,6 +1149,12 @@ ai_provider_image_exists() {
|
||||
docker image inspect "$AI_PROVIDER_IMAGE_NAME" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
read_ai_provider_image_fingerprint() {
|
||||
docker image inspect \
|
||||
--format '{{ index .Config.Labels "planet.aiprovider.build-fingerprint" }}' \
|
||||
"$AI_PROVIDER_IMAGE_NAME" 2>/dev/null || true
|
||||
}
|
||||
|
||||
list_ai_provider_containers() {
|
||||
docker ps -aq --filter "name=planet_aiprovider" 2>/dev/null || true
|
||||
}
|
||||
@@ -1166,15 +1216,28 @@ ensure_ai_provider_image_current() {
|
||||
local current_fingerprint=""
|
||||
local previous_fingerprint=""
|
||||
|
||||
prepare_uv_build_config
|
||||
|
||||
current_fingerprint="$(compute_ai_provider_build_fingerprint)"
|
||||
previous_fingerprint="$(read_ai_provider_build_stamp || true)"
|
||||
|
||||
if ai_provider_image_exists && [ -n "$previous_fingerprint" ] && [ "$current_fingerprint" = "$previous_fingerprint" ]; then
|
||||
AI_PROVIDER_RECREATE_REQUIRED=0
|
||||
return 0
|
||||
if ai_provider_image_exists; then
|
||||
local image_fingerprint
|
||||
image_fingerprint="$(read_ai_provider_image_fingerprint)"
|
||||
if [ -n "$image_fingerprint" ] && [ "$current_fingerprint" = "$image_fingerprint" ]; then
|
||||
write_ai_provider_build_stamp "$current_fingerprint"
|
||||
AI_PROVIDER_RECREATE_REQUIRED=0
|
||||
return 0
|
||||
fi
|
||||
if [ -z "$image_fingerprint" ] && [ -n "$previous_fingerprint" ] && [ "$current_fingerprint" = "$previous_fingerprint" ]; then
|
||||
AI_PROVIDER_RECREATE_REQUIRED=0
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
set_wait_detail "检测到 AI Provider 代码或配置变化,重建镜像"
|
||||
AI_PROVIDER_BUILD_FINGERPRINT="$current_fingerprint"
|
||||
export AI_PROVIDER_BUILD_FINGERPRINT
|
||||
|
||||
if ! compose_supports_build; then
|
||||
log_error "当前 docker compose 不支持 build,请检查 Docker / Compose 环境"
|
||||
@@ -1301,8 +1364,8 @@ ensure_uv_backend_deps() {
|
||||
"$DEPENDENCY_INSTALL_MAX_RETRIES" \
|
||||
"$DEPENDENCY_INSTALL_RETRY_INTERVAL" \
|
||||
"uv 环境初始化失败,已重试 ${DEPENDENCY_INSTALL_MAX_RETRIES} 次" \
|
||||
"uv sync" \
|
||||
run_command_quiet_unless_verbose "$log_file" uv sync --group dev; then
|
||||
"uv sync --frozen" \
|
||||
run_command_quiet_unless_verbose "$log_file" uv sync --frozen --group dev; then
|
||||
tail -20 "$log_file" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
@@ -1355,8 +1418,8 @@ sync_python_deps() {
|
||||
"$DEPENDENCY_INSTALL_MAX_RETRIES" \
|
||||
"$DEPENDENCY_INSTALL_RETRY_INTERVAL" \
|
||||
"uv 环境初始化失败,已重试 ${DEPENDENCY_INSTALL_MAX_RETRIES} 次" \
|
||||
"uv sync" \
|
||||
run_command_quiet_unless_verbose "$log_file" uv sync --group dev; then
|
||||
"uv sync --frozen" \
|
||||
run_command_quiet_unless_verbose "$log_file" uv sync --frozen --group dev; then
|
||||
tail -20 "$log_file" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
@@ -1911,7 +1974,7 @@ start_backend_with_retry() {
|
||||
fi
|
||||
cd "$SCRIPT_DIR/backend"
|
||||
: > "$BACKEND_LOG_FILE"
|
||||
PYTHONPATH="$SCRIPT_DIR/backend" nohup uv run --project "$SCRIPT_DIR" python -m uvicorn app.main:app --host "$backend_bind_host" --port "$backend_port" --reload > "$BACKEND_LOG_FILE" 2>&1 &
|
||||
PYTHONPATH="$SCRIPT_DIR/backend" nohup uv run --frozen --project "$SCRIPT_DIR" python -m uvicorn app.main:app --host "$backend_bind_host" --port "$backend_port" --reload > "$BACKEND_LOG_FILE" 2>&1 &
|
||||
BACKEND_PID=$!
|
||||
write_pid_file "$BACKEND_PID_FILE" "$BACKEND_PID"
|
||||
if [ "$VERBOSE" -eq 1 ]; then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "planet"
|
||||
version = "0.65.0"
|
||||
version = "0.65.2"
|
||||
description = "智能星球计划 - 态势感知系统"
|
||||
requires-python = ">=3.14"
|
||||
dependencies = [
|
||||
|
||||
@@ -64,7 +64,7 @@ sync_python_env() {
|
||||
echo -e "${BLUE}同步 Python 依赖...${NC}"
|
||||
cd "$ROOT_DIR"
|
||||
uv python install 3.14
|
||||
uv sync --group dev
|
||||
uv sync --frozen --group dev
|
||||
}
|
||||
|
||||
sync_frontend_env() {
|
||||
|
||||
Reference in New Issue
Block a user