@@ -91,6 +91,100 @@ docker run -d --name nodeprobe -p 8380:8380 \
9191
9292Data will be saved to ` /opt/NodeProbe/data/ ` by default.
9393
94+ ### Windows one-click deployment
95+
96+ Windows users can deploy NodeProbe with the following PowerShell script. Run it in an elevated PowerShell session:
97+
98+ ``` powershell
99+ # === NodeProbe one-click deployment (Docker Desktop / Windows) ===
100+ $ErrorActionPreference = 'Stop'
101+
102+ # 1) Configurable variables
103+ $Repo = "https://github.com/podcctv/NodeProbe"
104+ $Branch = "main"
105+ $WorkDir = "$env:USERPROFILE\NodeProbe"
106+ $ZipTmp = "$env:TEMP\nodeprobe.zip"
107+ $Image = "nodeprobe:latest"
108+ $Container = "nodeprobe"
109+ $HostPort = 8000 # Change if port is occupied
110+ $AppPort = 8000 # Service port inside container
111+
112+ # 2) Check Docker availability
113+ if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
114+ throw "Docker command not found. Install and start Docker Desktop first."
115+ }
116+ try { docker version | Out-Null } catch { throw "Docker Desktop is not running or has no permission to access the Docker engine." }
117+
118+ # 3) Prepare working directory
119+ if (Test-Path $WorkDir) {
120+ Write-Host "=> Directory exists: $WorkDir"
121+ } else {
122+ New-Item -ItemType Directory -Path $WorkDir | Out-Null
123+ Write-Host "=> Created directory: $WorkDir"
124+ }
125+
126+ # 4) Fetch source code (git preferred, ZIP fallback)
127+ if (Get-Command git -ErrorAction SilentlyContinue) {
128+ if (Test-Path (Join-Path $WorkDir ".git")) {
129+ Write-Host "=> Git repository detected, pulling updates..."
130+ git -C $WorkDir fetch --all --prune
131+ git -C $WorkDir checkout $Branch
132+ git -C $WorkDir reset --hard origin/$Branch
133+ } else {
134+ Write-Host "=> Using git clone..."
135+ git clone --depth 1 --branch $Branch $Repo $WorkDir
136+ }
137+ } else {
138+ Write-Host "=> Git not found, downloading ZIP..."
139+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
140+ Invoke-WebRequest "$Repo/archive/refs/heads/$Branch.zip" -OutFile $ZipTmp
141+ if (Test-Path $WorkDir) { Remove-Item -Recurse -Force $WorkDir }
142+ Expand-Archive -LiteralPath $ZipTmp -DestinationPath (Split-Path $WorkDir) -Force
143+ Rename-Item -Path (Join-Path (Split-Path $WorkDir) ("NodeProbe-" + $Branch)) -NewName (Split-Path $WorkDir -Leaf)
144+ }
145+
146+ # 5) Generate a generic Dockerfile if missing
147+ $Dockerfile = Join-Path $WorkDir "Dockerfile"
148+ if (-not (Test-Path $Dockerfile)) {
149+ Write-Host "=> Dockerfile not found, generating a generic version..."
150+ @"
151+ FROM python:3.11-slim
152+ WORKDIR /app
153+ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
154+ # Base dependencies (add more system libs as needed)
155+ RUN apt-get update && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/*
156+ COPY . .
157+ RUN python -m pip install --upgrade pip && \
158+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
159+ EXPOSE ${AppPort}
160+ # Entry point: adjust if your project uses a different module
161+ CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "${AppPort}"]
162+ "@ | Set-Content -Path $Dockerfile -Encoding UTF8
163+ }
164+
165+ # 6) Build image
166+ Write-Host "=> Building image: $Image"
167+ docker build -t $Image $WorkDir
168+
169+ # 7) Replace existing container
170+ if ((docker ps -a --format '{{.Names}}') -contains $Container) {
171+ Write-Host "=> Existing container found, removing: $Container"
172+ docker rm -f $Container | Out-Null
173+ }
174+
175+ # 8) Run container
176+ Write-Host "=> Starting container: $Container mapping port $HostPort -> $AppPort"
177+ docker run -d --name $Container -p $HostPort:$AppPort --restart unless-stopped $Image | Out-Null
178+
179+ # 9) Health check and access
180+ Start-Sleep -Seconds 2
181+ Write-Host "=> Recent logs (Ctrl+C to stop following):"
182+ docker logs --tail 50 $Container
183+ Write-Host "=> Open http://localhost:$HostPort in your browser"
184+ try { Start-Process "http://localhost:$HostPort" } catch {}
185+ Write-Host "=== Deployment complete ==="
186+ ```
187+
94188## Changelog
95189
96190For a list of notable changes, see [ CHANGELOG] ( CHANGELOG.md ) or the [ Chinese version] ( CHANGELOG.zh.md ) .
0 commit comments