fix: configure gitea webhook auto-deploy and fix provisioning NVS flash
- Add deploy-host.sh script for webhook-triggered docker redeploy - Mark deploy-host.sh executable in .gitignore / git config - Update docker-compose.yml and nginx.conf for auto-pull setup - Fix vite.config.js and admin router for deployment environment - Fix NVS generator CRC seed to match ESP-IDF esp_rom_crc32_le Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,3 +1,8 @@
|
||||
# Auto-deploy generated files
|
||||
deploy.sh
|
||||
deploy.log
|
||||
.deploy-trigger
|
||||
|
||||
# Secrets
|
||||
.env
|
||||
firebase-service-account.json
|
||||
@@ -25,4 +30,6 @@ dist/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.MAIN-APP-REFERENCE/
|
||||
.MAIN-APP-REFERENCE/
|
||||
|
||||
.project-vesper-plan.md
|
||||
@@ -42,23 +42,12 @@ async def deploy(request: Request):
|
||||
|
||||
logger.info("Auto-deploy triggered via Gitea webhook")
|
||||
|
||||
project_path = settings.deploy_project_path
|
||||
cmd = f"cd {project_path} && git pull origin main && docker compose up -d --build"
|
||||
try:
|
||||
proc = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
)
|
||||
stdout, _ = await asyncio.wait_for(proc.communicate(), timeout=300)
|
||||
output = stdout.decode(errors="replace") if stdout else ""
|
||||
# Write a trigger file to the host-mounted project path.
|
||||
# A host-side watcher service (bellsystems-deploy-watcher) polls for this
|
||||
# file and runs deploy-host.sh as the bellsystems user when it appears.
|
||||
trigger_path = f"{settings.deploy_project_path}/.deploy-trigger"
|
||||
with open(trigger_path, "w") as f:
|
||||
f.write("deploy\n")
|
||||
|
||||
if proc.returncode != 0:
|
||||
logger.error(f"Deploy failed (exit {proc.returncode}):\n{output}")
|
||||
raise HTTPException(status_code=500, detail=f"Deploy script failed:\n{output[-500:]}")
|
||||
|
||||
logger.info(f"Deploy succeeded:\n{output[-300:]}")
|
||||
return {"ok": True, "output": output[-1000:]}
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
raise HTTPException(status_code=504, detail="Deploy timed out after 300 seconds")
|
||||
logger.info("Auto-deploy trigger file written")
|
||||
return {"ok": True, "message": "Deploy started"}
|
||||
|
||||
11
deploy-host.sh
Executable file
11
deploy-host.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
PROJECT=/home/bellsystems/bellsystems-cp
|
||||
|
||||
echo "Deploy started at $(date)"
|
||||
cd "$PROJECT"
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
docker compose up -d --build 2>&1
|
||||
echo "Deploy finished at $(date)"
|
||||
@@ -10,6 +10,8 @@ services:
|
||||
- ./data/built_melodies:/app/storage/built_melodies
|
||||
- ./data/firmware:/app/storage/firmware
|
||||
- ./data/firebase-service-account.json:/app/firebase-service-account.json:ro
|
||||
# Auto-deploy: project root so container can write the trigger file
|
||||
- /home/bellsystems/bellsystems-cp:/home/bellsystems/bellsystems-cp
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on: []
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function Header() {
|
||||
}}
|
||||
>
|
||||
<h2 className="text-lg font-semibold" style={{ color: "var(--text-heading)" }}>
|
||||
BellSystems - Control Panel
|
||||
BellCloud™ - Console new 41 Nigga FUCK YOU
|
||||
</h2>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
@@ -41,3 +41,5 @@ export default function Header() {
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
/* my test string */
|
||||
@@ -7,6 +7,7 @@ export default defineConfig({
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
allowedHosts: ['console.bellsystems.net'],
|
||||
hmr: {
|
||||
clientPort: 80,
|
||||
},
|
||||
|
||||
@@ -3,18 +3,17 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
upstream backend {
|
||||
server backend:8000;
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
server frontend:5173;
|
||||
}
|
||||
client_max_body_size 10m;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Use Docker's internal DNS so nginx re-resolves after container restarts
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
set $backend_upstream http://backend:8000;
|
||||
set $frontend_upstream http://frontend:5173;
|
||||
|
||||
# OTA firmware files — allow browser (esptool-js) to fetch .bin files directly
|
||||
location /ota/ {
|
||||
root /srv;
|
||||
@@ -29,7 +28,7 @@ http {
|
||||
|
||||
# API requests → FastAPI backend
|
||||
location /api/ {
|
||||
proxy_pass http://backend;
|
||||
proxy_pass $backend_upstream$request_uri;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -38,7 +37,7 @@ http {
|
||||
|
||||
# WebSocket support for MQTT live data
|
||||
location /api/mqtt/ws {
|
||||
proxy_pass http://backend;
|
||||
proxy_pass $backend_upstream$request_uri;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
@@ -47,7 +46,7 @@ http {
|
||||
|
||||
# Everything else → React frontend (Vite dev server)
|
||||
location / {
|
||||
proxy_pass http://frontend;
|
||||
proxy_pass $frontend_upstream$request_uri;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user