Compare commits

1 Commits

Author SHA1 Message Date
78b3de07fc Añadir teable.sh 2025-11-29 15:55:26 +01:00

131
teable.sh Normal file
View File

@@ -0,0 +1,131 @@
#!/bin/bash
# =================================================================
# INSTALADOR DE TEABLE PARA VM DEDICADA (PROXMOX)
# - Docker Nativo
# - Postgres expuesto para Metabase externo
# =================================================================
# --- CONFIGURACIÓN ---
INSTALL_DIR="/opt/teable"
# Contraseña FUERTE para la base de datos (La necesitarás en Metabase)
DB_PASSWORD="Teable_Secure_Pass_2025!"
TEABLE_SECRET="Secret_$(openssl rand -hex 16)"
# Detectar IP local automáticamente para configuración inicial
CURRENT_IP=$(hostname -I | awk '{print $1}')
# Colores
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}>>> INICIANDO INSTALACIÓN EN VM <<<${NC}"
# 1. ACTUALIZAR SISTEMA E INSTALAR DEPENDENCIAS
echo -e "${GREEN}[+] Actualizando sistema...${NC}"
apt-get update && apt-get upgrade -y
apt-get install -y curl git nano ufw
# 2. INSTALAR DOCKER (Script Oficial)
if ! command -v docker &> /dev/null; then
echo -e "${GREEN}[+] Instalando Docker Nativo...${NC}"
curl -fsSL https://get.docker.com | sh
systemctl enable docker
systemctl start docker
else
echo "Docker ya estaba instalado."
fi
# 3. PREPARAR CARPETA
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
# 4. GENERAR DOCKER-COMPOSE
echo -e "${GREEN}[+] Generando configuración...${NC}"
cat <<EOF > docker-compose.yml
version: "3.9"
services:
teable:
image: ghcr.io/teableio/teable:latest
container_name: teable_app
restart: always
ports:
- "3000:3000"
environment:
# Puerto interno de la app
PORT: "3000"
# URL PÚBLICA (Importante para que cargue bien)
# Cuando tengas dominio, cambia esto a: https://tu-dominio.com
PUBLIC_ORIGIN: "http://${CURRENT_IP}:3000"
SECRET_KEY: "${TEABLE_SECRET}"
# Conexión a DB
DATABASE_URL: "postgresql://teable:${DB_PASSWORD}@postgres:5432/teable"
PRISMA_DATABASE_URL: "postgresql://teable:${DB_PASSWORD}@postgres:5432/teable"
REDIS_URL: "redis://redis:6379"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
volumes:
- teable_data:/app/.assets
postgres:
image: postgres:15-alpine
container_name: teable_postgres
restart: always
ports:
# EXPOSICIÓN PARA METABASE EXTERNO
# Mapeamos el 5432 del contenedor al 5432 de la VM
- "5432:5432"
environment:
POSTGRES_DB: teable
POSTGRES_USER: teable
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U teable"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: teable_redis
restart: always
volumes:
- redis_data:/data
volumes:
teable_data:
postgres_data:
redis_data:
EOF
# 5. ARRANCAR
echo -e "${GREEN}[+] Levantando Teable...${NC}"
docker compose up -d
echo -e "\n${BLUE}==========================================================${NC}"
echo -e "${GREEN} ¡INSTALACIÓN EN VM COMPLETADA! ${NC}"
echo -e "${BLUE}==========================================================${NC}"
echo -e "1. Acceso Web (Provisional): http://${CURRENT_IP}:3000"
echo -e ""
echo -e "2. Datos para conectar METABASE (Desde otro LXC/VM):"
echo -e " - Host: ${CURRENT_IP}"
echo -e " - Puerto: 5432"
echo -e " - Usuario: teable"
echo -e " - Password: ${DB_PASSWORD}"
echo -e " - Database: teable"
echo -e ""
echo -e "3. CUANDO TENGAS DOMINIO:"
echo -e " Edita /opt/teable/docker-compose.yml y cambia PUBLIC_ORIGIN"
echo -e " Luego haz: docker compose up -d"
echo -e "${BLUE}==========================================================${NC}"