Bump versions, add port auto-detection, require .env for WP

- Ollama: 0.32.6 → 0.33.0
- Open WebUI: 0.11.0 → 0.11.1
- WordPress: 7.0 → 7.1
- All compose: ports use env vars for auto-detection
- All deploy.sh: find_free_port() — increments port by 1 until free
- WordPress compose: MYSQL vars require .env (no insecure defaults)
- WordPress deploy.sh: auto-generates .env with random passwords
- WordPress deploy.sh: auto-detects ports for WP, Ollama, and WebUI
This commit is contained in:
devops
2026-08-27 00:38:32 +02:00
parent 2a1d629273
commit b7a8983b99
6 changed files with 152 additions and 52 deletions
+55 -20
View File
@@ -22,8 +22,8 @@ COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml"
echo ""
echo -e "${BOLD}${CYAN}╔══════════════════════════════════════════╗${NC}"
echo -e "${BOLD}${CYAN}║ d0a1 pack — WordPress Agéntico${NC}"
echo -e "${BOLD}${CYAN}║ WP + IA local. Sin cuotas. ║${NC}"
echo -e "${BOLD}${CYAN}║ d0a1 pack — WordPress + IA ${NC}"
echo -e "${BOLD}${CYAN}║ WP + IA local. Sin cuotas. ${NC}"
echo -e "${BOLD}${CYAN}╚══════════════════════════════════════════╝${NC}"
echo ""
@@ -38,6 +38,7 @@ fi
# ── Check Docker ────────────────────────────
if ! command -v docker &>/dev/null; then
echo -e "${RED}✗ Docker no está instalado.${NC}"
echo ""
echo "Instálalo: curl -fsSL https://get.docker.com | sh"
exit 1
fi
@@ -47,14 +48,6 @@ if ! docker compose version &>/dev/null; then
fi
echo -e "${GREEN}${NC} Docker: $(docker compose version --short 2>/dev/null || echo 'OK')"
# ── Check .env for passwords ──────────────────────
if [ ! -f "$SCRIPT_DIR/.env" ]; then
echo -e "${YELLOW}⚠ No .env file found. Creating from .env.example..."
cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env"
echo -e "${YELLOW}⚠ Edit $SCRIPT_DIR/.env to set your own passwords before deploying to production."
echo -e "${CYAN} nano $SCRIPT_DIR/.env"${NC}
fi
# ── Check RAM ───────────────────────────────
TOTAL_RAM_KB=$(grep MemTotal /proc/meminfo 2>/dev/null | awk '{print $2}' || echo "0")
TOTAL_RAM_GB=$((TOTAL_RAM_KB / 1024 / 1024))
@@ -64,25 +57,67 @@ if [ "$TOTAL_RAM_GB" -lt 5 ]; then
fi
echo -e "${GREEN}${NC} RAM: ${TOTAL_RAM_GB} GB"
# ── Setup .env ──────────────────────────────
if [ ! -f "$SCRIPT_DIR/.env" ]; then
echo -e "${YELLOW}⚠ No se encontró .env. Creando desde .env.example...${NC}"
cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env"
# Generate random passwords for local dev
ROOT_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1)
WP_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1)
sed -i "s/change-me-to-a-strong-password/${ROOT_PASS}/g" "$SCRIPT_DIR/.env"
# Second occurrence is MYSQL_PASSWORD
sed -i "0,/change-me-to-a-strong-password/{s/change-me-to-a-strong-password/${WP_PASS}/}" "$SCRIPT_DIR/.env"
echo -e "${GREEN}${NC} Contraseñas generadas en ${SCRIPT_DIR}/.env"
fi
# ── Auto-detect ports ───────────────────────
find_free_port() {
local port=$1
local max_port=$((port + 20))
while [ "$port" -le "$max_port" ]; do
if ! ss -tlnp 2>/dev/null | grep -q ":${port} " && ! netstat -tlnp 2>/dev/null | grep -q ":${port} "; then
echo "$port"
return 0
fi
port=$((port + 1))
done
echo "$1"
return 1
}
export OLLAMA_PORT=$(find_free_port 11434)
export WP_PORT=$(find_free_port 8080)
export WEBUI_PORT=$(find_free_port 3000)
# ── Mode info ───────────────────────────────
if [ "$MODE" = "local" ]; then
echo -e "${YELLOW}Modo:${NC} local (tu ordenador)"
echo -e " WordPress: ${CYAN}http://localhost:8080${NC}"
echo -e " IA (chat): ${CYAN}http://localhost:3000${NC}"
echo -e " WordPress: ${CYAN}http://localhost:${WP_PORT}${NC}"
echo -e " IA (chat): ${CYAN}http://localhost:${WEBUI_PORT}${NC}"
elif [ "$MODE" = "vps" ]; then
IP=$(hostname -I 2>/dev/null | awk '{print $1}' || echo 'TU_IP')
echo -e "${YELLOW}Modo:${NC} VPS (accesible desde fuera)"
echo -e " WordPress: ${CYAN}http://${IP}:8080${NC}"
echo -e " IA (chat): ${CYAN}http://${IP}:3000${NC}"
echo -e " WordPress: ${CYAN}http://${IP}:${WP_PORT}${NC}"
echo -e " IA (chat): ${CYAN}http://${IP}:${WEBUI_PORT}${NC}"
echo ""
echo -e " ${BOLD}¿No tienes VPS?${NC} Consigue uno con descuento:"
echo -e " ${CYAN}https://d0a1.es/go/vultr/ — Vultr"
echo -e " ${CYAN}https://d0a1.es/go/digitalocean/ — DigitalOcean ($200 credit)"
echo -e " ${CYAN}https://d0a1.es/go/vultr/${NC} — Vultr"
echo -e " ${CYAN}https://d0a1.es/go/digitalocean/${NC} — DigitalOcean (\$200 credit)"
else
echo -e "${RED}Modo desconocido: $MODE${NC}"
echo "Usa: ./deploy.sh local | vps | stop"
exit 1
fi
if [ "$OLLAMA_PORT" != "11434" ]; then
echo -e "${YELLOW}⚠ Puerto 11434 ocupado, usando ${OLLAMA_PORT}${NC}"
fi
if [ "$WP_PORT" != "8080" ]; then
echo -e "${YELLOW}⚠ Puerto 8080 ocupado, usando ${WP_PORT}${NC}"
fi
if [ "$WEBUI_PORT" != "3000" ]; then
echo -e "${YELLOW}⚠ Puerto 3000 ocupado, usando ${WEBUI_PORT}${NC}"
fi
echo ""
# ── Deploy ──────────────────────────────────
@@ -108,11 +143,11 @@ echo ""
echo -e "${BOLD}${GREEN}¡Listo! Tu WordPress con IA está corriendo.${NC}"
echo ""
if [ "$MODE" = "local" ]; then
echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://localhost:8080${NC}"
echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://localhost:3000${NC}"
echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://localhost:${WP_PORT}${NC}"
echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://localhost:${WEBUI_PORT}${NC}"
else
echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://${IP}:8080${NC}"
echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://${IP}:3000${NC}"
echo -e " ${BOLD}WordPress:${NC} ${CYAN}http://${IP}:${WP_PORT}${NC}"
echo -e " ${BOLD}IA (chat):${NC} ${CYAN}http://${IP}:${WEBUI_PORT}${NC}"
fi
echo ""
echo -e " ${BOLD}Configurar WordPress:${NC}"
+6 -6
View File
@@ -27,10 +27,10 @@ services:
wordpress:
container_name: d0a1-wp
image: wordpress:7.0-php8.4-apache
image: wordpress:7.1-php8.4-apache
restart: unless-stopped
ports:
- "8080:80"
- "${WP_PORT:-8080}:80"
volumes:
- wp_data:/var/www/html
environment:
@@ -44,10 +44,10 @@ services:
ollama:
container_name: d0a1-wp-ollama
image: ollama/ollama:0.32.6
image: ollama/ollama:0.33.0
restart: unless-stopped
ports:
- "127.0.0.1:11434:11434"
- "127.0.0.1:${OLLAMA_PORT:-11434}:11434"
volumes:
- ollama_data:/root/.ollama
environment:
@@ -62,10 +62,10 @@ services:
openwebui:
container_name: d0a1-wp-openwebui
image: ghcr.io/open-webui/open-webui:0.11.0
image: ghcr.io/open-webui/open-webui:0.11.1
restart: unless-stopped
ports:
- "3000:8080"
- "${WEBUI_PORT:-3000}:8080"
volumes:
- openwebui_data:/app/backend/data
environment: