- Implemented Docker operations including image building, container management, and resource stats. - Added Gitea API client for repository management and webhook handling. - Introduced monitoring service to collect and store container metrics in InfluxDB. - Created a queue system using BullMQ for managing deployment jobs with real-time log streaming. - Developed Telegram notification service for deployment status updates. - Added Traefik label generation for dynamic reverse proxy configuration. - Implemented WebSocket endpoints for log streaming and terminal access to containers. - Created an updater sidecar for self-updating the AutoDeployer container.
46 lines
1.1 KiB
Bash
46 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# AutoDeployer self-update sidecar
|
|
# Watches for a trigger file and rebuilds the autodeployer container.
|
|
|
|
PROJECT_DIR="/project"
|
|
TRIGGER_FILE="/trigger/update-trigger"
|
|
LOG_FILE="/trigger/update.log"
|
|
|
|
log() {
|
|
echo "[$(date -Iseconds)] $1" | tee -a "$LOG_FILE"
|
|
}
|
|
|
|
do_update() {
|
|
log "=== Self-update triggered ==="
|
|
cd "$PROJECT_DIR" || { log "ERROR: project dir not found"; return 1; }
|
|
|
|
log "Pulling latest changes..."
|
|
if ! git pull --ff-only 2>&1 | tee -a "$LOG_FILE"; then
|
|
log "ERROR: git pull failed"
|
|
echo "failed" > /trigger/update-status
|
|
return 1
|
|
fi
|
|
|
|
log "Rebuilding autodeployer..."
|
|
if ! docker compose up -d --build --no-deps autodeployer 2>&1 | tee -a "$LOG_FILE"; then
|
|
log "ERROR: docker compose up failed"
|
|
echo "failed" > /trigger/update-status
|
|
return 1
|
|
fi
|
|
|
|
log "=== Self-update completed ==="
|
|
echo "success" > /trigger/update-status
|
|
return 0
|
|
}
|
|
|
|
log "Updater sidecar started, watching $TRIGGER_FILE"
|
|
|
|
while true; do
|
|
if [ -f "$TRIGGER_FILE" ]; then
|
|
rm -f "$TRIGGER_FILE"
|
|
echo "updating" > /trigger/update-status
|
|
do_update
|
|
fi
|
|
sleep 2
|
|
done
|