diff --git a/.dockerignore b/.dockerignore new file mode 100755 index 0000000..0445e70 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,50 @@ +# Archivos y directorios a excluir de Docker + +# .dockerignore (no necesita estar en la imagen) +.dockerignore + +# Git +.git +.gitignore + +# Entorno +.env +.env.* +.env.local + +# Documentación +README.md +docs/ +*.md + +# Docker (toda la carpeta de configuración Docker) +docker/ + +# OS +.DS_Store +Thumbs.db + +# Logs y archivos temporales +*.log +*.tmp +*.swp +*~ + +# Uploads (se monta como volumen) +uploads/* +!uploads/.gitkeep + +# Base de datos +*.sql +*.sqlite +database/migrations/ + +# IDE +.idea/ +.vscode/ +*.sublime-* + +# Cache +.cache/ +tmp/ +vendor/ diff --git a/.env b/.env index 8598393..a4bdbc1 100755 --- a/.env +++ b/.env @@ -1,17 +1,17 @@ # Entorno de aplicación APP_ENV=local -SITE_URL=http://10.10.4.3:82 +SITE_URL=http://ibiza-test.casa # Base de datos local/desarrollo LOCAL_DB_HOST=10.10.4.17 -LOCAL_DB_PORT=3390 +LOCAL_DB_PORT=3391 LOCAL_DB_USER=nickpons666 LOCAL_DB_PASS=MiPo6425@@ LOCAL_DB_NAME=ibiza_db2 # Base de datos de producción SERVER_DB_HOST=10.10.4.17 -SERVER_DB_PORT=3390 +SERVER_DB_PORT=3391 SERVER_DB_USER=nickpons666 SERVER_DB_PASS=MiPo6425@@ SERVER_DB_NAME=ibiza_db diff --git a/build-and-push.sh b/build-and-push.sh new file mode 100755 index 0000000..55aa381 --- /dev/null +++ b/build-and-push.sh @@ -0,0 +1,208 @@ +#!/bin/bash + +# Script interactivo para crear imagen Docker y subirla al registry +# Uso: ./build-and-push.sh + +set -e + +# Colores para output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuración por defecto +REGISTRY_URL="10.10.4.3:5000" +IMAGE_NAME="condominio_ibiza" +DOCKERFILE_PATH="docker/Dockerfile" +PROJECT_DIR="/var/www/html/ibiza" + +# Función para imprimir mensajes +print_info() { + echo -e "${BLUE}ℹ️ $1${NC}" +} + +print_success() { + echo -e "${GREEN}✅ $1${NC}" +} + +print_warning() { + echo -e "${YELLOW}⚠️ $1${NC}" +} + +print_error() { + echo -e "${RED}❌ $1${NC}" +} + +# Verificar que estamos en el directorio correcto +if [ ! -f "$DOCKERFILE_PATH" ]; then + print_error "No se encontró el Dockerfile en $DOCKERFILE_PATH" + print_info "Asegúrate de ejecutar este script desde el directorio raíz del proyecto" + exit 1 +fi + +# Mostrar banner +echo "" +echo "╔════════════════════════════════════════════════════════╗" +echo "║ 🐳 BUILD & PUSH - Condominio Ibiza Docker ║" +echo "╚════════════════════════════════════════════════════════╝" +echo "" + +# Paso 1: Preguntar versión/tag +print_info "Paso 1: Versión de la imagen" +echo "" +read -p "Ingresa la versión/tag (ej: v2.1, latest, o deja en blanco para 'latest'): " VERSION + +if [ -z "$VERSION" ]; then + VERSION="latest" +fi + +print_info "Versión seleccionada: $VERSION" +echo "" + +# Paso 2: Confirmar registry +print_info "Paso 2: Configuración del Registry" +echo "" +read -p "Registry URL [$REGISTRY_URL]: " INPUT_REGISTRY +REGISTRY_URL=${INPUT_REGISTRY:-$REGISTRY_URL} +print_info "Registry: $REGISTRY_URL" +echo "" + +# Paso 3: Seleccionar modo de build +print_info "Paso 3: Modo de construcción" +echo "" +echo "Selecciona el modo de build:" +echo " 1) Con caché (más rápido, reutiliza capas anteriores)" +echo " 2) Sin caché (--no-cache, fuerza reconstrucción completa)" +echo "" +read -p "Opción [1]: " BUILD_OPTION + +USE_CACHE="s" +if [ "$BUILD_OPTION" == "2" ]; then + USE_CACHE="n" + print_info "Modo seleccionado: Sin caché (build completo)" +else + print_info "Modo seleccionado: Con caché (build rápido)" +fi +echo "" + +# Mostrar resumen antes de comenzar +echo "" +echo "╔════════════════════════════════════════════════════════╗" +echo "║ 📋 RESUMEN DE OPERACIÓN ║" +echo "╠════════════════════════════════════════════════════════╣" +echo "║ Imagen: $IMAGE_NAME:$VERSION" +echo "║ Registry: $REGISTRY_URL" +echo "║ Dockerfile: $DOCKERFILE_PATH" +if [ "$USE_CACHE" == "n" ]; then +echo "║ Modo: Sin caché (build completo)" +else +echo "║ Modo: Con caché (build rápido)" +fi +echo "╚════════════════════════════════════════════════════════╝" +echo "" + +read -p "¿Deseas continuar? (s/n): " CONFIRM +if [[ $CONFIRM != "s" && $CONFIRM != "S" ]]; then + print_warning "Operación cancelada por el usuario" + exit 0 +fi + +echo "" +print_info "🚀 Iniciando proceso..." +echo "" + +# Paso 4: Build de la imagen +print_info "Paso 4: Construyendo imagen Docker..." + +if [ "$USE_CACHE" == "n" ]; then + echo " Comando: docker build --no-cache -t $IMAGE_NAME:$VERSION -f $DOCKERFILE_PATH ." + echo "" + if docker build --no-cache -t "$IMAGE_NAME:$VERSION" -f "$DOCKERFILE_PATH" .; then + print_success "Imagen construida exitosamente (sin caché): $IMAGE_NAME:$VERSION" + else + print_error "Error al construir la imagen" + exit 1 + fi +else + echo " Comando: docker build -t $IMAGE_NAME:$VERSION -f $DOCKERFILE_PATH ." + echo "" + if docker build -t "$IMAGE_NAME:$VERSION" -f "$DOCKERFILE_PATH" .; then + print_success "Imagen construida exitosamente: $IMAGE_NAME:$VERSION" + else + print_error "Error al construir la imagen" + exit 1 + fi +fi + +echo "" + +# Paso 5: Taggear para el registry +print_info "Paso 5: Taggeando imagen para registry..." +echo " Comando: docker tag $IMAGE_NAME:$VERSION $REGISTRY_URL/$IMAGE_NAME:$VERSION" +echo "" + +if docker tag "$IMAGE_NAME:$VERSION" "$REGISTRY_URL/$IMAGE_NAME:$VERSION"; then + print_success "Imagen taggeada: $REGISTRY_URL/$IMAGE_NAME:$VERSION" +else + print_error "Error al taggear la imagen" + exit 1 +fi + +echo "" + +# Paso 6: Subir al registry +read -p "¿Deseas subir la imagen al registry ahora? (s/n): " PUSH_CONFIRM + +if [[ $PUSH_CONFIRM == "s" || $PUSH_CONFIRM == "S" ]]; then + print_info "Paso 6: Subiendo imagen al registry..." + echo " Comando: docker push $REGISTRY_URL/$IMAGE_NAME:$VERSION" + echo "" + + if docker push "$REGISTRY_URL/$IMAGE_NAME:$VERSION"; then + print_success "Imagen subida exitosamente al registry" + else + print_error "Error al subir la imagen al registry" + print_warning "Verifica que el registry esté accesible en $REGISTRY_URL" + print_info "Puedes intentar subir manualmente con: docker push $REGISTRY_URL/$IMAGE_NAME:$VERSION" + exit 1 + fi +else + print_warning "Imagen NO subida al registry" + print_info "Puedes subirla manualmente después con:" + echo " docker push $REGISTRY_URL/$IMAGE_NAME:$VERSION" +fi + +echo "" + +# Paso 7: Limpiar imágenes locales (opcional) +read -p "¿Deseas eliminar las imágenes locales para liberar espacio? (s/n): " CLEANUP_CONFIRM + +if [[ $CLEANUP_CONFIRM == "s" || $CLEANUP_CONFIRM == "S" ]]; then + print_info "Limpiando imágenes locales..." + docker rmi "$IMAGE_NAME:$VERSION" "$REGISTRY_URL/$IMAGE_NAME:$VERSION" 2>/dev/null || true + print_success "Imágenes locales eliminadas" +fi + +echo "" +echo "╔════════════════════════════════════════════════════════╗" +echo "║ ✅ PROCESO COMPLETADO ║" +echo "╠════════════════════════════════════════════════════════╣" +echo "║ Imagen: $REGISTRY_URL/$IMAGE_NAME:$VERSION" +echo "╚════════════════════════════════════════════════════════╝" +echo "" + +print_info "Para usar esta imagen en ZimaOS/CasaOS:" +echo "" +echo "1. Actualiza tu archivo ibiza.yaml:" +echo " image: $REGISTRY_URL/$IMAGE_NAME:$VERSION" +echo "" +echo "2. Reinicia el contenedor en ZimaOS/CasaOS" +echo "" +echo "3. Verifica los logs:" +echo " docker logs condominio_ibiza" +echo "" + +print_success "¡Listo!" +echo "" diff --git a/daemon.json b/daemon.json new file mode 100755 index 0000000..99bcfbb --- /dev/null +++ b/daemon.json @@ -0,0 +1,3 @@ +{ + "insecure-registries": ["10.10.4.17:5000"] +} \ No newline at end of file diff --git a/dashboard.php b/dashboard.php index e248846..a4353de 100755 --- a/dashboard.php +++ b/dashboard.php @@ -717,6 +717,61 @@ switch ($page) { } exit; + case 'save_all_concept_payments': + if ($_SERVER['REQUEST_METHOD'] !== 'POST') { + echo json_encode(['success' => false, 'message' => 'Método no permitido']); + exit; + } + $input = json_decode(file_get_contents('php://input'), true); + if ($input) { + $conceptId = $input['concept_id'] ?? 0; + $payments = $input['payments'] ?? []; + + if (!$conceptId || !is_array($payments)) { + echo json_encode(['success' => false, 'message' => 'Datos de pago incompletos o inválidos']); + exit; + } + if (!Auth::isCapturist()) { + echo json_encode(['success' => false, 'message' => 'Permiso denegado']); + exit; + } + + $savedCount = 0; + $errorCount = 0; + + foreach ($payments as $payment) { + $houseId = $payment['house_id'] ?? 0; + $amount = $payment['amount'] ?? 0; + $paymentDate = $payment['payment_date'] ?? null; + + if (!$houseId) { + $errorCount++; + continue; + } + + $result = CollectionPayment::update($conceptId, $houseId, $amount, $userId, 'Pago actualizado', $paymentDate); + if ($result) { + $savedCount++; + } else { + $errorCount++; + } + } + + if ($savedCount > 0) { + Auth::logActivity('save_all_concept_payments', 'Múltiples pagos de concepto guardados: Concepto ' . $conceptId . ', ' . $savedCount . ' pagos guardados'); + if ($errorCount > 0) { + echo json_encode(['success' => true, 'message' => 'Se guardaron ' . $savedCount . ' pagos. Hubo ' . $errorCount . ' errores.']); + } else { + echo json_encode(['success' => true, 'message' => 'Se guardaron ' . $savedCount . ' pagos exitosamente']); + } + } else { + echo json_encode(['success' => false, 'message' => 'No se pudo guardar ningún pago']); + } + } else { + echo json_encode(['success' => false, 'message' => 'Datos inválidos']); + } + exit; + default: echo json_encode(['success' => false, 'message' => 'Acción no válida para la vista de concepto']); exit; diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..0319858 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Script de entrada para Docker +set -e + +# Función para crear archivo .env desde variables de entorno +create_env_file() { + if [ ! -f /var/www/html/ibiza/.env ] || [ ! -s /var/www/html/ibiza/.env ]; then + echo "Creando archivo .env desde variables de entorno..." + + cat > /var/www/html/ibiza/.env << EOF +# Entorno de aplicación +APP_ENV=${APP_ENV:-local} +SITE_URL=${SITE_URL:-http://localhost} + +# Base de datos +DB_HOST=${DB_HOST:-localhost} +DB_PORT=${DB_PORT:-3306} +DB_USER=${DB_USER:-root} +DB_PASS=${DB_PASS:-} +DB_NAME=${DB_NAME:-ibiza_db} + +# Base de datos local/desarrollo +LOCAL_DB_HOST=${DB_HOST:-localhost} +LOCAL_DB_PORT=${DB_PORT:-3306} +LOCAL_DB_USER=${DB_USER:-root} +LOCAL_DB_PASS=${DB_PASS:-} +LOCAL_DB_NAME=${DB_NAME:-ibiza_db} + +# Base de datos de producción +SERVER_DB_HOST=${DB_HOST:-localhost} +SERVER_DB_PORT=${DB_PORT:-3306} +SERVER_DB_USER=${DB_USER:-root} +SERVER_DB_PASS=${DB_PASS:-} +SERVER_DB_NAME=${DB_NAME:-ibiza_db} + +# Configuración de sesión +SESSION_TIMEOUT=${SESSION_TIMEOUT:-28800} +JWT_SECRET=${JWT_SECRET:-ibiza_jwt_secret_key_CHANGE_IN_PRODUCTION_2025!@#} +JWT_EXPIRATION=${JWT_EXPIRATION:-86400} +EOF + + echo "Archivo .env creado exitosamente" + chown www-data:www-data /var/www/html/ibiza/.env + fi +} + +# Crear archivo .env si no existe +create_env_file + +# Iniciar Apache en primer plano +exec /usr/sbin/apache2ctl -D FOREGROUND \ No newline at end of file diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100755 index 0000000..33005d2 --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1,13 @@ +# Archivos a excluir de Docker +.git +.gitignore +.env +.env.example +README.md +docs/ +.DS_Store +Thumbs.db +*.log +*.tmp +uploads/* +!uploads/.gitkeep \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100755 index 0000000..0d137c9 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,85 @@ +# Usar Ubuntu como base +FROM ubuntu:22.04 + +# Evitar interactividad durante instalación +ENV DEBIAN_FRONTEND=noninteractive + +# Actualizar sistema e instalar dependencias +RUN apt-get update && apt-get install -y \ + apache2 \ + php8.1 \ + php8.1-mysql \ + php8.1-pdo \ + php8.1-mbstring \ + php8.1-xml \ + php8.1-curl \ + php8.1-gd \ + php8.1-zip \ + php8.1-tokenizer \ + php8.1-bcmath \ + php8.1-intl \ + php8.1-ldap \ + php8.1-soap \ + php8.1-xsl \ + php8.1-imagick \ + libapache2-mod-php8.1 \ + curl \ + wget \ + unzip \ + git \ + composer \ + bash \ + bash-completion \ + readline-common \ + nano \ + less \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Habilitar módulos de Apache +RUN a2enmod rewrite \ + && a2enmod headers \ + && a2enmod expires + +# Configurar Apache +RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf \ + && sed -i 's/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/html\/ibiza/g' /etc/apache2/sites-available/000-default.conf + +# Configurar PHP +RUN sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 64M/g' /etc/php/8.1/apache2/php.ini \ + && sed -i 's/post_max_size = 8M/post_max_size = 64M/g' /etc/php/8.1/apache2/php.ini \ + && sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php/8.1/apache2/php.ini \ + && sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/8.1/apache2/php.ini + +# Crear directorio de la aplicación +WORKDIR /var/www/html/ibiza + +# Copiar archivos de la aplicación con el owner correcto +COPY --chown=www-data:www-data . . + +# Instalar dependencias de Composer +RUN composer install --no-dev --optimize-autoloader --no-interaction || true + +# Crear directorios necesarios +RUN mkdir -p /var/www/html/ibiza/uploads + +# Configurar permisos +RUN chown -R www-data:www-data /var/www/html/ibiza \ + && chmod -R 755 /var/www/html/ibiza \ + && chmod -R 777 /var/www/html/ibiza/uploads \ + && touch /var/www/html/ibiza/.env \ + && chown www-data:www-data /var/www/html/ibiza/.env + +# Exponer puertos +EXPOSE 80 443 + +# Script de inicio +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +# Asegurar que Apache pueda correr como www-data +RUN sed -i 's/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=www-data/g' /etc/apache2/envvars \ + && sed -i 's/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=www-data/g' /etc/apache2/envvars + +# Iniciar Apache +CMD ["docker-entrypoint.sh"] diff --git a/docker/README.md b/docker/README.md new file mode 100755 index 0000000..3e56b4b --- /dev/null +++ b/docker/README.md @@ -0,0 +1,102 @@ +# Docker - Archivos para crear imagen y registry + +Este directorio contiene TODOS los archivos Docker organizados y centralizados. + +## 🐳 Crear Imagen Docker +- `Dockerfile` - Configuración del contenedor Ubuntu + Apache + PHP +- `docker-entrypoint.sh` - Script de inicio para el contenedor +- `docker-compose.yml` - Para pruebas locales +- `.dockerignore` - Excluir archivos innecesarios + +## 📦 Registry Docker Privado +- `daemon.json` - Configuración Docker para registry local +- Scripts para configuración en servidor remoto + +## 🏠 CasaOS Installation +- `casaos-sin-env-completo.yml` - ✅ **RECOMENDADO** (sin errores) +- `casaos-sin-env.yml` - Versión simple sin .env +- `casaos-simple-final.yml` - Versión corregida +- `casaos-registry-corregido.yml` - Con metadatos completos +- Y otros archivos YAML para diferentes necesidades + +## 🔧 Scripts y Configuración +- `corregir-forzado-registry.sh` - ✅ **DEFINITIVO** para error HTTP/HTTPS +- `diagnostico-registry.sh` - Script de diagnóstico completo +- `corregir-insecure-registry.sh` - Corrección rápida +- `configurar-servidor-remoto.sh` - Configuración básica + +## 📖 Instrucciones +- `INSTRUCCIONES_SERVIDOR_REMOTO.txt` - Guía completa y actualizada +- `instrucciones_cortas.txt` - Versión rápida con comandos + +## 📁 Estructura Completa + +``` +docker/ +├── 🐳 Imagen Docker (4 archivos) +├── 🏠 CasaOS YAML (7 archivos) +├── 🔧 Scripts (4 archivos) +├── ⚙️ Configuración (1 archivo) +├── 📖 Documentación (2 archivos) +└── 📂 yamls/ (directorio extra) +``` + +**Total: 18 archivos organizados** + +## 📁 Estructura + +``` +docker/ +├── 🐳 Imagen Docker +│ ├── Dockerfile +│ ├── docker-entrypoint.sh +│ ├── docker-compose.yml +│ └── .dockerignore +│ +├── 📦 Registry Privado +│ └── daemon.json +│ +├── 🏠 CasaOS Installation +│ ├── casaos-simple-final.yml +│ ├── casaos-sin-env.yml +│ ├── casaos-sin-env-completo.yml +│ └── casaos-registry-corregido.yml +│ +├── 🔧 Scripts y Configuración +│ ├── configurar-servidor-remoto.sh +│ ├── diagnostico-registry.sh +│ ├── corregir-insecure-registry.sh +│ └── corregir-forzado-registry.sh +│ +└── 📖 Documentación + ├── INSTRUCCIONES_SERVIDOR_REMOTO.txt + └── instrucciones_cortas.txt +``` + +## 🚀 Uso Rápido + +### Crear imagen Docker localmente: +```bash +cd /var/www/html/ibiza/docker/ +docker compose build +docker compose up -d +``` + +### Configurar registry en servidor remoto (10.10.4.17): +```bash +curl -s http://10.10.4.3:82/docker/corregir-forzado-registry.sh | bash +``` + +### Instalar en CasaOS (versión recomendada): +```bash +wget http://10.10.4.3:82/docker/casaos-sin-env-completo.yml +# Importar en CasaOS → Apps → Install App +``` + +### Acceder al sistema: +- Local: http://10.10.4.3:8080 +- Remoto: http://10.10.4.17:8080 +- Usuario: admin / Contraseña: admin123 + +--- +*Todos los archivos centralizados y organizados en este directorio Docker.* \ No newline at end of file diff --git a/docker/comandos_subir_imagen.txt b/docker/comandos_subir_imagen.txt new file mode 100755 index 0000000..40ee9e1 --- /dev/null +++ b/docker/comandos_subir_imagen.txt @@ -0,0 +1,57 @@ +# Comandos para crear y subir imagen a registry + +# IMPORTANTE: Ejecutar desde /var/www/html/ibiza (directorio padre de docker/) + +# ============================================================ +# OPCIÓN 1: Usar tag :latest +# ============================================================ + +# 1. Hacer build de la imagen +docker build -t condominio_ibiza:latest -f docker/Dockerfile . + +# 2. Taggear la imagen para el registry remoto +docker tag condominio_ibiza:latest 10.10.4.3:5000/condominio_ibiza:latest + +# 3. Subir la imagen al registry +docker push 10.10.4.3:5000/condominio_ibiza:latest + +# ============================================================ +# OPCIÓN 2: Usar tag de versión (recomendado) +# ============================================================ + +# 1. Hacer build de la imagen +docker build -t condominio_ibiza:v2 -f docker/Dockerfile . + +# 2. Taggear la imagen para el registry remoto +docker tag condominio_ibiza:v2 10.10.4.3:5000/condominio_ibiza:v2 + +# 3. Subir la imagen al registry +docker push 10.10.4.3:5000/condominio_ibiza:v2 + +# 4. (Opcional) Verificar que se subio correctamente +docker pull 10.10.4.3:5000/condominio_ibiza:v2 + +# ============================================================ +# VARIABLES DE ENTORNO (configuradas en ibiza.yaml para CasaOS) +# ============================================================ +# Las variables sensibles NO se incluyen en el .env copiado. +# Se pasan como environment variables en el contenedor: +# +# APP_ENV=production +# DB_HOST=10.10.4.17 +# DB_NAME=ibiza_db +# DB_PASS=MiPo6425@@ +# DB_PORT=3390 +# DB_USER=nickpons666 +# JWT_EXPIRATION=86400 +# JWT_SECRET=ibiza_jwt_secret_key_CHANGE_IN_PRODUCTION_2025!@# +# SESSION_TIMEOUT=28800 +# SITE_URL=https://condominioibiza.ddns.net +# +# El archivo .env se crea automáticamente en docker-entrypoint.sh +# usando estas variables de entorno. +# ============================================================ + +# Nota: Asegurese de que el daemon.json tenga configurado el registry como insecure +# Si no lo tiene, agregar "10.10.4.3:5000" a "insecure-registries" y reiniciar docker: +# sudo systemctl restart docker diff --git a/docker/configurar-registry-remoto.sh b/docker/configurar-registry-remoto.sh new file mode 100755 index 0000000..7498da1 --- /dev/null +++ b/docker/configurar-registry-remoto.sh @@ -0,0 +1,16 @@ +# Comandos para configurar Docker en el servidor remoto + +# 1. Crear archivo de configuración +sudo mkdir -p /etc/docker +cat << 'EOF' | sudo tee /etc/docker/daemon.json +{ + "insecure-registries": ["10.10.4.17:5000"] +} +EOF + +# 2. Reiniciar Docker +sudo systemctl restart docker + +# 3. Verificar configuración +sudo docker info | grep -A 10 "Insecure Registries" +EOF \ No newline at end of file diff --git a/docker/configurar-servidor-remoto.sh b/docker/configurar-servidor-remoto.sh new file mode 100755 index 0000000..f68c4b5 --- /dev/null +++ b/docker/configurar-servidor-remoto.sh @@ -0,0 +1,24 @@ +# Comandos para configurar Docker en el servidor remoto (10.10.4.17) + +# 1. Crear archivo de configuración con IP correcta +sudo mkdir -p /etc/docker +cat << 'EOF' | sudo tee /etc/docker/daemon.json +{ + "insecure-registries": ["10.10.4.3:5000"] +} +EOF + +# 2. Reiniciar Docker +sudo systemctl restart docker + +# 3. Verificar configuración +sudo docker info | grep -A 10 "Insecure Registries" + +# 4. Probar conexión al registry +curl http://10.10.4.3:5000/v2/_catalog + +# 5. Probar bajar la imagen +docker pull 10.10.4.3:5000/condominio_ibiza:latest + +# 6. Listar imágenes para verificar +docker images | grep condominio_ibiza \ No newline at end of file diff --git a/docker/corregir-forzado-registry.sh b/docker/corregir-forzado-registry.sh new file mode 100755 index 0000000..ce03bc8 --- /dev/null +++ b/docker/corregir-forzado-registry.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# Script de corrección forzada para el problema de Docker registry + +echo "=== CORRECCIÓN FORZADA DE DOCKER REGISTRY ===" +echo "" + +echo "1. Eliminando configuración anterior..." +sudo rm -f /etc/docker/daemon.json +sudo rm -f /etc/docker/daemon.json.bak + +echo "" +echo "2. Creando nueva configuración..." +sudo mkdir -p /etc/docker + +# Método 1: Usando echo +echo '{"insecure-registries": ["10.10.4.3:5000"]}' | sudo tee /etc/docker/daemon.json + +echo "" +echo "3. Verificando archivo creado..." +echo "Contenido de /etc/docker/daemon.json:" +sudo cat /etc/docker/daemon.json + +echo "" +echo "4. Verificando sintaxis JSON..." +if python3 -c "import json; json.load(open('/etc/docker/daemon.json'))" 2>/dev/null; then + echo "✅ JSON válido" +else + echo "❌ JSON inválido" +fi + +echo "" +echo "5. Reiniciando Docker..." +sudo systemctl restart docker +sudo systemctl status docker --no-pager -l + +echo "" +echo "6. Esperando 10 segundos..." +sleep 10 + +echo "" +echo "7. Verificando configuración de Docker..." +sudo docker info | grep -A 15 "Insecure Registries" + +echo "" +echo "8. Probando descarga de imagen..." +if sudo docker pull 10.10.4.3:5000/condominio_ibiza:latest; then + echo "✅ IMAGEN DESCARGADA EXITOSAMENTE" + echo "" + echo "Imágenes disponibles:" + sudo docker images | grep condominio +else + echo "❌ FALLÓ LA DESCARGA" + echo "" + echo "Intentando método alternativo..." + echo "" + + # Método alternativo: Configuración directa + echo "9. Intentando método alternativo..." + sudo mkdir -p /etc/docker/systemd + sudo bash -c 'cat > /etc/docker/systemd/docker.service << "EOF" +[Unit] +Description=Docker Application Container Engine +Documentation=https://docs.docker.com +After=network.target docker.socket +Requires=docker.socket + +[Service] +Type=notify +ExecStart=/usr/bin/dockerd --insecure-registry=10.10.4.3:5000 +ExecReload=/bin/kill -s HUP $MAINPID +LimitNOFILE=infinity +LimitNPROC=infinity +LimitCORE=infinity +TasksMax=infinity +TimeoutStartSec=0 +Delegate=yes +KillMode=process +Restart=on-failure +StartLimitBurst=3 +StartLimitInterval=60s + +[Install] +WantedBy=multi-user.target +EOF' + + echo "" + echo "10. Recargando systemd y reiniciando Docker..." + sudo systemctl daemon-reload + sudo systemctl restart docker + sleep 5 + + echo "" + echo "11. Intentando descarga final..." + if sudo docker pull 10.10.4.3:5000/condominio_ibiza:latest; then + echo "✅ MÉTODO ALTERNATIVO FUNCIONÓ" + sudo docker images | grep condominio + else + echo "❌ TODOS LOS MÉTODOS FALLARON" + echo "Requiere configuración manual" + fi +fi + +echo "" +echo "=== FIN DE CORRECCIÓN FORZADA ===" \ No newline at end of file diff --git a/docker/corregir-insecure-registry.sh b/docker/corregir-insecure-registry.sh new file mode 100755 index 0000000..82c343b --- /dev/null +++ b/docker/corregir-insecure-registry.sh @@ -0,0 +1,21 @@ +# En el servidor remoto (10.10.4.17) + +# 1. Verificar configuración actual +cat /etc/docker/daemon.json + +# 2. Si está incorrecto, corregirlo +sudo mkdir -p /etc/docker +sudo tee /etc/docker/daemon.json << 'EOF' +{ + "insecure-registries": ["10.10.4.3:5000"] +} +EOF + +# 3. Reiniciar Docker (¡importante!) +sudo systemctl restart docker + +# 4. Verificar que se aplicó +sudo docker info | grep -A 5 "Insecure Registries" + +# 5. Probar de nuevo +docker pull 10.10.4.3:5000/condominio_ibiza:latest \ No newline at end of file diff --git a/docker/daemon.json b/docker/daemon.json new file mode 100755 index 0000000..99bcfbb --- /dev/null +++ b/docker/daemon.json @@ -0,0 +1,3 @@ +{ + "insecure-registries": ["10.10.4.17:5000"] +} \ No newline at end of file diff --git a/docker/diagnostico-registry.sh b/docker/diagnostico-registry.sh new file mode 100755 index 0000000..472c548 --- /dev/null +++ b/docker/diagnostico-registry.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Script completo para diagnosticar y corregir el problema del registry + +echo "=== DIAGNÓSTICO DE REGISTRY DOCKER ===" +echo "Servidor actual: $(hostname)" +echo "IP del registry: 10.10.4.3:5000" +echo "" + +echo "1. Verificando archivo daemon.json..." +if [ -f /etc/docker/daemon.json ]; then + echo "Contenido actual de /etc/docker/daemon.json:" + cat /etc/docker/daemon.json + echo "" +else + echo "❌ No existe /etc/docker/daemon.json" +fi + +echo "" +echo "2. Verificando configuración de Docker..." +if sudo docker info 2>/dev/null | grep -q "Insecure Registries"; then + echo "✅ Insecure Registries configurados:" + sudo docker info | grep -A 5 "Insecure Registries" +else + echo "❌ No hay Insecure Registries configurados" +fi + +echo "" +echo "3. Probando conexión al registry..." +if curl -s http://10.10.4.3:5000/v2/_catalog >/dev/null 2>&1; then + echo "✅ Registry accesible: $(curl -s http://10.10.4.3:5000/v2/_catalog)" +else + echo "❌ No se puede acceder al registry" +fi + +echo "" +echo "4. Corrigiendo configuración..." +sudo mkdir -p /etc/docker + +# Eliminar archivo existente para evitar conflictos +sudo rm -f /etc/docker/daemon.json + +# Crear nuevo archivo con formato exacto +sudo bash -c 'cat > /etc/docker/daemon.json << "EOF" +{ + "insecure-registries": ["10.10.4.3:5000"] +} +EOF' + +echo "✅ Archivo daemon.json actualizado" + +echo "" +echo "5. Reiniciando Docker..." +sudo systemctl restart docker + +echo "⏳ Esperando 5 segundos..." +sleep 5 + +echo "" +echo "6. Verificando que el archivo fue creado correctamente..." +if [ -f /etc/docker/daemon.json ]; then + echo "✅ Archivo daemon.json creado:" + cat /etc/docker/daemon.json + echo "" +else + echo "❌ No se pudo crear /etc/docker/daemon.json" +fi + +echo "" +echo "7. Verificando configuración de Docker..." +if sudo docker info 2>/dev/null | grep -q "10.10.4.3:5000"; then + echo "✅ Insecure Registry correctamente configurado:" + sudo docker info | grep -A 10 "Insecure Registries" +else + echo "❌ Falló la configuración del registry" + echo "Mostrando todos los Insecure Registries:" + sudo docker info | grep -A 10 "Insecure Registries" +fi + +echo "" +echo "7. Probando descargar imagen..." +if sudo docker pull 10.10.4.3:5000/condominio_ibiza:latest; then + echo "✅ Imagen descargada exitosamente" + sudo docker images | grep condominio_ibiza +else + echo "❌ Falló la descarga de la imagen" +fi + +echo "" +echo "=== FIN DEL DIAGNÓSTICO ===" \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100755 index 0000000..797676d --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,37 @@ +version: '3.8' + +services: + condominio_ibiza: + build: + context: .. + dockerfile: docker/Dockerfile + container_name: condominio_ibiza + ports: + - "8080:80" + - "8443:443" + environment: + # Entorno de aplicación + - APP_ENV=local + - SITE_URL=http://localhost:8080 + + # Configuración de base de datos (modificar según tu configuración) + - DB_HOST=10.10.4.17 + - DB_PORT=3391 + - DB_USER=nickpons666 + - DB_PASS=MiPo6425@@ + - DB_NAME=ibiza_db2 + + # Configuración de sesión + - SESSION_TIMEOUT=28800 + - JWT_SECRET=ibiza_jwt_secret_key_CHANGE_IN_PRODUCTION_2025!@# + - JWT_EXPIRATION=86400 + volumes: + - ./uploads:/var/www/html/ibiza/uploads + - ./.env:/var/www/html/ibiza/.env + restart: unless-stopped + networks: + - ibiza_network + +networks: + ibiza_network: + driver: bridge \ No newline at end of file diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100755 index 0000000..386b796 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Script de entrada para Docker +set -e + +# Función para crear archivo .env desde variables de entorno +create_env_file() { + if [ ! -f /var/www/html/ibiza/.env ] || [ ! -s /var/www/html/ibiza/.env ]; then + echo "Creando archivo .env desde variables de entorno..." + + cat > /var/www/html/ibiza/.env << EOF +# Entorno de aplicación +APP_ENV=${APP_ENV:-local} +SITE_URL=${SITE_URL:-http://localhost} + +# Base de datos +DB_HOST=${DB_HOST:-localhost} +DB_PORT=${DB_PORT:-3306} +DB_USER=${DB_USER:-root} +DB_PASS=${DB_PASS:-} +DB_NAME=${DB_NAME:-ibiza_db} + +# Base de datos local/desarrollo +LOCAL_DB_HOST=${DB_HOST:-localhost} +LOCAL_DB_PORT=${DB_PORT:-3306} +LOCAL_DB_USER=${DB_USER:-root} +LOCAL_DB_PASS=${DB_PASS:-} +LOCAL_DB_NAME=${DB_NAME:-ibiza_db} + +# Base de datos de producción +SERVER_DB_HOST=${DB_HOST:-localhost} +SERVER_DB_PORT=${DB_PORT:-3306} +SERVER_DB_USER=${DB_USER:-root} +SERVER_DB_PASS=${DB_PASS:-} +SERVER_DB_NAME=${DB_NAME:-ibiza_db} + +# Configuración de sesión +SESSION_TIMEOUT=${SESSION_TIMEOUT:-28800} +JWT_SECRET=${JWT_SECRET:-ibiza_jwt_secret_key_CHANGE_IN_PRODUCTION_2025!@#} +JWT_EXPIRATION=${JWT_EXPIRATION:-86400} +EOF + + echo "Archivo .env creado exitosamente" + chown www-data:www-data /var/www/html/ibiza/.env + fi +} + +# Crear archivo .env si no existe +create_env_file + +# Corregir permisos de volúmenes montados (importante para ZimaOS/CasaOS) +echo "Corrigiendo permisos de volúmenes montados..." +chown -R www-data:www-data /var/www/html/ibiza || true +chmod -R 755 /var/www/html/ibiza || true +chmod -R 777 /var/www/html/ibiza/uploads 2>/dev/null || true +chmod 777 /var/www/html/ibiza/.env 2>/dev/null || true + +# Configurar Apache para correr como www-data +export APACHE_RUN_USER=www-data +export APACHE_RUN_GROUP=www-data + +echo "Permisos corregidos. Iniciando Apache..." + +# Iniciar Apache en primer plano +exec /usr/sbin/apache2ctl -D FOREGROUND \ No newline at end of file diff --git a/docker/ibiza.yaml b/docker/ibiza.yaml new file mode 100755 index 0000000..fabed46 --- /dev/null +++ b/docker/ibiza.yaml @@ -0,0 +1,59 @@ +name: condominio-ibiza +services: + app: + cpu_shares: 90 + command: [] + container_name: condominio_ibiza + deploy: + resources: + limits: + memory: 16655581184 + reservations: + devices: [] + environment: + - APP_ENV=production + - DB_HOST=10.10.4.17 + - DB_NAME=ibiza_db + - DB_PASS=MiPo6425@@ + - DB_PORT=3390 + - DB_USER=nickpons666 + - JWT_EXPIRATION=86400 + - JWT_SECRET=ibiza_jwt_secret_key_CHANGE_IN_PRODUCTION_2025!@# + - SESSION_TIMEOUT=28800 + - SITE_URL=https://condominioibiza.ddns.net + hostname: condominio_ibiza + image: 10.10.4.3:5000/condominio_ibiza:latest + labels: + icon: https://www.punta-diamante.saredesarrollo.com.mx/storage/img/condominios/6/VBgcKjrcQCCQ7gIlGousPfH9EECJ4UluHwAThjJ2.png + ports: + - target: 80 + published: "8085" + protocol: tcp + - target: 443 + published: "8443" + protocol: tcp + restart: unless-stopped + volumes: + - type: bind + source: /media/sda/AppData/condominioibiza/uploads + target: /var/www/html/ibiza/uploads + - type: bind + source: /media/sda/AppData/condominioibiza/logs + target: /var/www/html/ibiza/logs + devices: [] + cap_add: [] + network_mode: bridge + privileged: false +x-casaos: + author: self + category: self + hostname: "" + icon: https://www.punta-diamante.saredesarrollo.com.mx/storage/img/condominios/6/VBgcKjrcQCCQ7gIlGousPfH9EECJ4UluHwAThjJ2.png + index: / + is_uncontrolled: false + port_map: "8085" + scheme: http + store_app_id: condominio-ibiza + title: + custom: ibiza + en_us: app diff --git a/docker/probar-registry-remoto.sh b/docker/probar-registry-remoto.sh new file mode 100755 index 0000000..ff08d5d --- /dev/null +++ b/docker/probar-registry-remoto.sh @@ -0,0 +1,8 @@ +# Probar conexión al registry desde servidor remoto +curl http://10.10.4.17:5000/v2/_catalog + +# Probar bajar la imagen +docker pull 10.10.4.17:5000/condominio_ibiza:latest + +# Listar imágenes para verificar +docker images | grep condominio_ibiza \ No newline at end of file diff --git a/docker/registry/comandos_actualizar_grub.txt b/docker/registry/comandos_actualizar_grub.txt new file mode 100755 index 0000000..b903fa2 --- /dev/null +++ b/docker/registry/comandos_actualizar_grub.txt @@ -0,0 +1,121 @@ +COMANDOS PARA ACTUALIZAR GRUB DESPUÉS DE ELIMINAR WINDOWS +======================================================== + +COMANDOS PARA EJECUTAR DESDE LIVE CD/UBUNTU LIVE +================================================ + +PASO 1: IDENTIFICAR PARTICIÓN DE UBUNTU +-------------------------------------- +sudo fdisk -l + +Busca tu partición Linux (probablemente sda5 con formato ext4) + +PASO 2: MONTAR PARTICIÓN DE UBUNTU +---------------------------------- +sudo mkdir /mnt/ubuntu +sudo mount /dev/sda5 /mnt/ubuntu + +PASO 3: MONTAR PARTICIONES NECESARIAS PARA CHROOT +--------------------------------------------------- +sudo mount /dev/sda1 /mnt/ubuntu/boot/efi # Partición EFI +sudo mount --bind /dev /mnt/ubuntu/dev +sudo mount --bind /proc /mnt/ubuntu/proc +sudo mount --bind /sys /mnt/ubuntu/sys +sudo mount --bind /run /mnt/ubuntu/run + +PASO 4: ACTIVAR SWAP (si es necesario) +------------------------------------- +sudo swapon /dev/sda6 + +PASO 5: ENTRAR AL SISTEMA UBUNTU (CHROOT) +----------------------------------------- +sudo chroot /mnt/ubuntu + +AHORA DENTRO DE TU SISTEMA UBUNTU (ya no estás en Live CD): +========================================================= + +PASO 6: ACTUALIZAR CONFIGURACIÓN DE GRUB +--------------------------------------- +update-grub + +Este comando buscará sistemas operativos y eliminará las entradas de Windows. + +PASO 7: REINSTALAR GRUB EN EL DISCO +------------------------------------ +grub-install /dev/sda + +Esto reinstala GRUB correctamente después de los cambios de partición. + +PASO 8: VERIFICAR CONFIGURACIÓN +------------------------------- +grub-mkconfig -o /boot/grub/grub.cfg + +PASO 9: SALIR DEL CHROOT +------------------------ +exit + +PASO 10: DESMONTAR TODO CORRECTAMENTE +------------------------------------- +sudo umount -R /mnt/ubuntu +sudo swapoff /dev/sda6 + +PASO 11: REINICIAR EL SISTEMA +----------------------------- +reboot + +COMANDOS DE VERIFICACIÓN (OPCIONAL) +================================== + +PARA VERIFICAR ANTES DE REINICIAR (desde Live CD): +------------------------------------------------- + +1. Verificar particiones montadas: +mount | grep /mnt/ubuntu + +2. Verificar que se montó todo correctamente: +ls -la /mnt/ubuntu/boot/efi + +3. Verificar GRUB desde chroot: +(chroot) dpkg -l | grep grub + +TROUBLESHOOTING DESDE LIVE CD +============================= + +SI EL MONTAJE FALLA: +------------------- +- Intenta: sudo fsck -f /dev/sda5 +- Verifica que /dev/sda5 sea la partición correcta con: sudo blkid + +SI CHROOT NO FUNCIONA: +--------------------- +- Verifica que todas las monturas estén correctas: + sudo mount | grep /mnt/ubuntu +- Intenta montar /dev/pts también: + sudo mount --bind /dev/pts /mnt/ubuntu/dev/pts + +SI GRUB-INSTALL FALLA: +-------------------- +- Intenta: grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu /dev/sda +- O si usas BIOS: grub-install --target=i386-pc /dev/sda + +SI UPDATE-GRUB NO DETECTA EL KERNEL: +----------------------------------- +- Desde chroot: apt update && apt install linux-image-generic + +NOTAS CRÍTICAS PARA LIVE CD +=========================== + +- TODOS los comandos PASOS 1-5 se ejecutan en Live CD +- Los comandos PASOS 6-8 se ejecutan DENTRO del chroot +- Si no estás seguro de la partición, ejecuta: sudo lsblk -f +- La partición EFI siempre es /dev/sda1 (100MB) +- Tu partición Linux debería ser /dev/sda5 después de redimensionar +- Asegúrate de tener internet antes del chroot: sudo dhclient + +VERIFICACIÓN FINAL +================= + +Después de reiniciar en Ubuntu normal, ejecuta: +lsblk +df -h +grub-editenv list \ No newline at end of file diff --git a/docker/registry/como_subir_imagenes.txt b/docker/registry/como_subir_imagenes.txt new file mode 100755 index 0000000..c60b2d9 --- /dev/null +++ b/docker/registry/como_subir_imagenes.txt @@ -0,0 +1,112 @@ +COMO SUBIR IMÁGENES A DOCKER REGISTRY +===================================== + +1. ETIQUETAR LA IMAGEN +--------------------- +Para subir una imagen al registry local, primero debes etiquetarla: + +docker tag : localhost:5000/: + +Ejemplo: +docker tag mi-app:latest localhost:5000/mi-app:latest + +2. SUBIR LA IMAGEN AL REGISTRY +------------------------------ +Una vez etiquetada, sube la imagen: + +docker push localhost:5000/: + +Ejemplo: +docker push localhost:5000/mi-app:latest + +3. VERIFICAR QUE LA IMAGEN ESTÁ EN EL REGISTRY +---------------------------------------------- +Puedes verificar las imágenes en el registry usando: + +curl -X GET http://localhost:5000/v2/_catalog + +O accediendo a la UI web en: http://localhost:8081 + +4. DESCARGAR LA IMAGEN DESDE EL REGISTRY +---------------------------------------- +Para descargar la imagen desde el registry: + +docker pull localhost:5000/: + +Ejemplo: +docker pull localhost:5000/mi-app:latest + +COMO SUBIR ACTUALIZACIONES DE LA IMAGEN +====================================== + +1. HACER CAMBIOS A TU IMAGEN +---------------------------- +Realiza los cambios necesarios en tu Dockerfile o código fuente. + +2. CONSTRUIR LA NUEVA VERSIÓN +------------------------------ +Construye la nueva versión de la imagen: + +docker build -t : . + +Ejemplo con versión: +docker build -t mi-app:v2.0 . + +O si quieres mantener el mismo tag: +docker build -t mi-app:latest . + +3. ETIQUETAR PARA EL REGISTRY +------------------------------ +Etiqueta la nueva versión para el registry: + +docker tag : localhost:5000/: + +Ejemplo: +docker tag mi-app:v2.0 localhost:5000/mi-app:v2.0 + +4. SUBIR LA ACTUALIZACIÓN +------------------------- +Sube la nueva versión al registry: + +docker push localhost:5000/: + +Ejemplo: +docker push localhost:5000/mi-app:v2.0 + +5. VERIFICAR LA ACTUALIZACIÓN +----------------------------- +Verifica que la nueva versión esté disponible: + +curl -X GET http://localhost:5000/v2//tags/list + +Ejemplo: +curl -X GET http://localhost:5000/v2/mi-app/tags/list + +NOTAS IMPORTANTES +================ + +- Siempre verifica que la imagen se construyó correctamente antes de subirla +- Puedes mantener múltiples versiones usando diferentes tags (v1.0, v1.1, v2.0, etc.) +- El tag 'latest' siempre apuntará a la última versión que subas con ese tag +- Para eliminar imágenes antiguas del registry, necesitarás usar la API de eliminación +- La UI web en http://localhost:8081 te permite ver todas las imágenes y sus tags + +EJEMPLO COMPLETO DE WORKFLOW +============================ + +# 1. Construir imagen +docker build -t mi-app:1.0 . + +# 2. Etiquetar para registry +docker tag mi-app:1.0 localhost:5000/mi-app:1.0 + +# 3. Subir a registry +docker push localhost:5000/mi-app:1.0 + +# 4. Para actualizar +docker build -t mi-app:1.1 . +docker tag mi-app:1.1 localhost:5000/mi-app:1.1 +docker push localhost:5000/mi-app:1.1 + +# 5. Verificar +curl http://localhost:5000/v2/mi-app/tags/list \ No newline at end of file diff --git a/docker/registry/docker-compose.yml b/docker/registry/docker-compose.yml new file mode 100755 index 0000000..9984be3 --- /dev/null +++ b/docker/registry/docker-compose.yml @@ -0,0 +1,29 @@ +version: '3.8' + +services: + docker-registry: + image: registry:2.8.3 + container_name: docker-registry + ports: + - "5000:5000" + environment: + - REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin=[http://localhost:8081] + - REGISTRY_HTTP_HEADERS_Access-Control-Allow-Methods=[HEAD,GET,OPTIONS,DELETE] + - REGISTRY_HTTP_HEADERS_Access-Control-Allow-Credentials=[true] + - REGISTRY_HTTP_HEADERS_Access-Control-Allow-Headers=[Authorization,Accept,Origin,Destination,Content-Type,Docker-Content-Digest] + - REGISTRY_HTTP_HEADERS_Access-Control-Expose-Headers=[Docker-Content-Digest] + volumes: + - ./data:/var/lib/registry + restart: unless-stopped + + registry-ui: + image: joxit/docker-registry-ui:latest + container_name: registry-ui + ports: + - "8081:80" + environment: + - REGISTRY_URL=http://docker-registry:5000 + depends_on: + - docker-registry + restart: unless-stopped + diff --git a/docker/registry/registry-ui-only.yml b/docker/registry/registry-ui-only.yml new file mode 100755 index 0000000..ea5b3b7 --- /dev/null +++ b/docker/registry/registry-ui-only.yml @@ -0,0 +1,11 @@ +version: '3.8' + +services: + registry-ui: + image: joxit/docker-registry-ui:latest + container_name: registry-ui + ports: + - "8081:80" + environment: + - REGISTRY_URL=http://localhost:5000 + restart: unless-stopped \ No newline at end of file diff --git a/install.php b/install.php index 9a8beb1..50d0145 100755 --- a/install.php +++ b/install.php @@ -1,16 +1,87 @@ getMessage() . "\n"; + echo "\nVerifique la configuración en el archivo .env\n"; + exit(1); +} + +// Verificar/crear base de datos +try { + $pdo->exec("CREATE DATABASE IF NOT EXISTS `" . DB_NAME . "` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + $pdo->exec("USE `" . DB_NAME . "`"); + echo "✓ Base de datos verificada/creada: " . DB_NAME . "\n\n"; +} catch (PDOException $e) { + echo "✗ Error al crear base de datos: " . $e->getMessage() . "\n"; exit(1); } @@ -45,3 +127,4 @@ echo "Usuario por defecto:\n"; echo " Usuario: admin\n"; echo " Contraseña: admin123\n\n"; echo "Acceda al sistema en: " . SITE_URL . "/login.php\n"; +echo "\nPara Docker, asegúrese de que las variables de entorno estén configuradas correctamente.\n"; \ No newline at end of file diff --git a/uploads/.gitkeep b/uploads/.gitkeep deleted file mode 100755 index e69de29..0000000 diff --git a/views/finance/concept_view.php b/views/finance/concept_view.php index d95ede8..4f6c2c6 100755 --- a/views/finance/concept_view.php +++ b/views/finance/concept_view.php @@ -70,6 +70,13 @@ Esto actualizará todos los pagos a $0.00 + +
+ +
+
@@ -78,9 +85,6 @@ - - - @@ -104,18 +108,18 @@ - - -
Propietario Monto Fecha de PagoAcciones
- -
+ +
+ +
+ @@ -394,12 +398,99 @@ window.saveConceptPayment = function(btn) { Swal.fire('Error', data.message, 'error'); } }) - .catch(function(error) { + .catch(function(error) { console.error('Save payment error:', error); Swal.fire('Error', 'Ocurrió un error: ' + error.message, 'error'); }); }; +window.saveAllConceptPayments = function() { + const rows = document.querySelectorAll('tbody tr[data-payment-id]'); + const payments = []; + let hasChanges = false; + + rows.forEach(function(row) { + const cell = row.querySelector('.payment-cell'); + const dateInput = row.querySelector('.payment-date-input'); + const houseId = row.dataset.houseId; + const originalAmount = parseFloat(cell.dataset.amount) || 0; + const value = cell.textContent.trim(); + const amount = parseFloat(value.replace(/[^0-9.-]+/g, '')) || 0; + const paymentDate = dateInput ? dateInput.value : null; + const originalDate = cell.dataset.paymentDate || ''; + + // Solo incluir si hay cambios + if (amount !== originalAmount || paymentDate !== originalDate) { + hasChanges = true; + payments.push({ + house_id: houseId, + amount: amount, + payment_date: paymentDate + }); + } + }); + + if (!hasChanges) { + Swal.fire('Info', 'No hay cambios para guardar', 'info'); + return; + } + + // Deshabilitar botones mientras se guarda + const btnTop = document.getElementById('save-all-payments-btn-top'); + const btnBottom = document.getElementById('save-all-payments-btn-bottom'); + if (btnTop) { + btnTop.disabled = true; + btnTop.innerHTML = ' Guardando...'; + } + if (btnBottom) { + btnBottom.disabled = true; + btnBottom.innerHTML = ' Guardando...'; + } + + fetch('/dashboard.php?page=concept_view_actions&action=save_all_concept_payments', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + concept_id: '', + payments: payments + }) + }) + .then(function(r) { + return r.json(); + }) + .then(function(data) { + if (data.success) { + Swal.fire('Éxito', data.message || 'Pagos guardados correctamente', 'success').then(function() { + location.reload(); + }); + } else { + Swal.fire('Error', data.message, 'error'); + // Rehabilitar botones + if (btnTop) { + btnTop.disabled = false; + btnTop.innerHTML = ' Guardar Todo'; + } + if (btnBottom) { + btnBottom.disabled = false; + btnBottom.innerHTML = ' Guardar Todo'; + } + } + }) + .catch(function(error) { + console.error('Save all payments error:', error); + Swal.fire('Error', 'Ocurrió un error: ' + error.message, 'error'); + // Rehabilitar botones + if (btnTop) { + btnTop.disabled = false; + btnTop.innerHTML = ' Guardar Todo'; + } + if (btnBottom) { + btnBottom.disabled = false; + btnBottom.innerHTML = ' Guardar Todo'; + } + }); +}; + // Attach event listener to button const initButton = document.getElementById('init-payments-btn'); if (initButton) {