diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..49c85ce
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,48 @@
+# Git
+.git
+.gitignore
+
+# Docker
+docker
+
+# Node modules (si hubiera)
+node_modules
+
+# Logs
+logs/*
+!logs/.gitkeep
+
+# Archivos temporales
+*.log
+*.tmp
+*.swp
+*.swo
+*~
+
+# IDE
+.idea
+.vscode
+*.sublime-*
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Archivos de desarrollo
+.env.local
+.env.*.local
+*.md
+!README.md
+
+# Tests
+tests
+phpunit.xml
+.phpunit.result.cache
+
+# Composer
+vendor
+!vendor/.gitkeep
+
+# Archivos de upload temporales
+galeria/*
+!galeria/.gitkeep
diff --git a/database/.gitkeep b/database/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d6c84a0..7389c7b 100755
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,19 +1,52 @@
-FROM php:8.2-cli
+FROM php:8.3-apache
+# Instalar dependencias del sistema
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
libzip-dev \
+ libpng-dev \
+ libjpeg-dev \
+ libfreetype6-dev \
unzip \
supervisor \
nano \
- && pecl install curl \
- && docker-php-ext-enable curl \
- && docker-php-ext-install pdo_mysql zip \
+ cron \
+ && docker-php-ext-configure gd --with-freetype --with-jpeg \
+ && docker-php-ext-install pdo_mysql zip gd curl \
+ && pecl install redis \
+ && docker-php-ext-enable redis \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
+# Habilitar módulos de Apache
+RUN a2enmod rewrite headers ssl
+
+# Copiar Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
-WORKDIR /var/www/html
+# Crear directorio de logs
+RUN mkdir -p /var/www/html/logs && chown -R www-data:www-data /var/www/html/logs
-CMD ["/usr/bin/supervisord", "-c", "/var/www/html/docker/supervisord.conf"]
+# Copiar configuración de Apache
+COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
+
+# Copiar configuración de Supervisor
+COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
+
+# Copiar el proyecto completo
+COPY . /var/www/html/
+
+# Instalar dependencias de PHP
+RUN composer install --no-dev --optimize-autoloader
+
+# Permisos correctos
+RUN chown -R www-data:www-data /var/www/html \
+ && chmod -R 755 /var/www/html \
+ && chmod -R 775 /var/www/html/logs \
+ && chmod -R 775 /var/www/html/galeria
+
+# Puerto expuesto
+EXPOSE 80
+
+# Iniciar Apache y Supervisor
+CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
diff --git a/docker/apache.conf b/docker/apache.conf
new file mode 100644
index 0000000..54bd15c
--- /dev/null
+++ b/docker/apache.conf
@@ -0,0 +1,33 @@
+
+ ServerAdmin webmaster@localhost
+ DocumentRoot /var/www/html
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+ # Permitir acceso a archivos estáticos
+
+ Require all granted
+
+
+
+ # Logs
+ ErrorLog ${APACHE_LOG_DIR}/error.log
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+ # Aumentar límites para uploads
+ LimitRequestBody 10485760
+
+ # Timeout para scripts largos
+ TimeOut 300
+
+
+# Configuración de PHP
+
+ php_value upload_max_filesize 10M
+ php_value post_max_size 10M
+ php_value max_execution_time 300
+ php_value max_input_time 300
+
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 313aa61..919e8b4 100755
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,34 +1,52 @@
version: '3.8'
services:
- bot:
- image: php:8.2-cli
- container_name: lastwar_bot
+ app:
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ container_name: lastwar_app
restart: unless-stopped
- volumes:
- - ../lastwar:/var/www/html/lastwar
- working_dir: /var/www/html/lastwar
- command: /usr/local/bin/supervisord -c /var/www/html/lastwar/docker/supervisord.conf
+ ports:
+ - "8080:80"
+ env_file:
+ - ../.env
environment:
- - PHP_DISPLAY_ERRORS=On
- - PHP_ERROR_REPORTING=E_ALL
+ - DB_HOST=db
+ - DB_PORT=3306
+ - DB_NAME=${DB_NAME:-lastwar}
+ - DB_USER=${DB_USER:-lastwar}
+ - DB_PASS=${DB_PASS:-}
+ - LIBRETRANSLATE_URL=http://libretranslate:5000
+ volumes:
+ - app_logs:/var/www/html/logs
+ - app_galeria:/var/www/html/galeria
networks:
- - bot_network
+ - lastwar_network
depends_on:
- - db
+ db:
+ condition: service_healthy
+ libretranslate:
+ condition: service_started
db:
image: mysql:8.0
container_name: lastwar_db
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD: ${DB_PASS:-}
- MYSQL_DATABASE: ${DB_NAME:-bot}
+ MYSQL_ROOT_PASSWORD: ${DB_PASS:-rootpassword}
+ MYSQL_DATABASE: ${DB_NAME:-lastwar}
+ MYSQL_USER: ${DB_USER:-lastwar}
+ MYSQL_PASSWORD: ${DB_PASS:-}
volumes:
- db_data:/var/lib/mysql
- - ./db:/docker-entrypoint-initdb.d
+ - ../database:/docker-entrypoint-initdb.d:ro
networks:
- - bot_network
+ - lastwar_network
+ healthcheck:
+ test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
+ timeout: 20s
+ retries: 10
libretranslate:
image: libretranslate/libretranslate
@@ -37,11 +55,18 @@ services:
ports:
- "5000:5000"
networks:
- - bot_network
+ - lastwar_network
+ healthcheck:
+ test: ["CMD-SHELL", "curl -f http://localhost:5000/languages || exit 1"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
networks:
- bot_network:
+ lastwar_network:
driver: bridge
volumes:
db_data:
+ app_logs:
+ app_galeria:
diff --git a/docker/supervisor_process_queue.conf b/docker/supervisor_process_queue.conf
deleted file mode 100755
index b0554eb..0000000
--- a/docker/supervisor_process_queue.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[program:bot_process_queue]
-process_name=%(program_name)s_%(process_num)02d
-command=php /var/www/html/lastwar/process_queue.php
-autostart=true
-autorestart=true
-user=www-data
-numprocs=1
-stdout_logfile=/var/www/html/lastwar/logs/process_queue.log
-stdout_logfile_maxbytes=10MB
-stderr_logfile=/var/www/html/lastwar/logs/process_queue_error.log
-redirect_stderr=true
diff --git a/docker/supervisor_translation_queue.conf b/docker/supervisor_translation_queue.conf
deleted file mode 100755
index 0d790ae..0000000
--- a/docker/supervisor_translation_queue.conf
+++ /dev/null
@@ -1,11 +0,0 @@
-[program:bot_translation_queue]
-process_name=%(program_name)s_%(process_num)02d
-command=php /var/www/html/lastwar/process_translation_queue.php
-autostart=true
-autorestart=true
-user=www-data
-numprocs=1
-stdout_logfile=/var/www/html/lastwar/logs/translation_queue.log
-stdout_logfile_maxbytes=10MB
-stderr_logfile=/var/www/html/lastwar/logs/translation_queue_error.log
-redirect_stderr=true
diff --git a/docker/supervisord.conf b/docker/supervisord.conf
index 191b516..f30d0c5 100755
--- a/docker/supervisord.conf
+++ b/docker/supervisord.conf
@@ -1,44 +1,51 @@
[supervisord]
nodaemon=true
-logfile=/var/www/html/lastwar/logs/supervisor.log
+logfile=/var/www/html/logs/supervisor.log
logfile_maxbytes=50MB
pidfile=/var/run/supervisord.pid
-childlogdir=/var/www/html/lastwar/logs
+childlogdir=/var/www/html/logs
+
+[program:apache]
+process_name=%(program_name)s
+command=/usr/sbin/apache2ctl -D FOREGROUND
+autostart=true
+autorestart=true
+stdout_logfile=/var/www/html/logs/apache.log
+stdout_logfile_maxbytes=10MB
+stderr_logfile=/var/www/html/logs/apache_error.log
+redirect_stderr=true
[program:bot_discord]
process_name=%(program_name)s
-command=php /var/www/html/lastwar/discord_bot.php
+command=php /var/www/html/discord_bot.php
autostart=true
autorestart=true
-user=www-data
numprocs=1
-stdout_logfile=/var/www/html/lastwar/logs/discord_bot.log
+stdout_logfile=/var/www/html/logs/discord_bot.log
stdout_logfile_maxbytes=10MB
-stderr_logfile=/var/www/html/lastwar/logs/discord_bot_error.log
+stderr_logfile=/var/www/html/logs/discord_bot_error.log
redirect_stderr=true
[program:bot_process_queue]
process_name=%(program_name)s
-command=php /var/www/html/lastwar/process_queue.php
+command=php /var/www/html/process_queue.php
autostart=true
autorestart=true
-user=www-data
numprocs=1
-stdout_logfile=/var/www/html/lastwar/logs/process_queue.log
+stdout_logfile=/var/www/html/logs/process_queue.log
stdout_logfile_maxbytes=10MB
-stderr_logfile=/var/www/html/lastwar/logs/process_queue_error.log
+stderr_logfile=/var/www/html/logs/process_queue_error.log
redirect_stderr=true
[program:bot_translation_queue]
process_name=%(program_name)s
-command=php /var/www/html/lastwar/process_translation_queue.php
+command=php /var/www/html/process_translation_queue.php
autostart=true
autorestart=true
-user=www-data
numprocs=1
-stdout_logfile=/var/www/html/lastwar/logs/translation_queue.log
+stdout_logfile=/var/www/html/logs/translation_queue.log
stdout_logfile_maxbytes=10MB
-stderr_logfile=/var/www/html/lastwar/logs/translation_queue_error.log
+stderr_logfile=/var/www/html/logs/translation_queue_error.log
redirect_stderr=true
[group:bot_workers]
diff --git a/galeria/.gitkeep b/galeria/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/logs/.gitkeep b/logs/.gitkeep
new file mode 100644
index 0000000..e69de29