Feature: Reescribir configuración Docker completa
- Dockerfile: PHP 8.3 con Apache, copia todo el código a la imagen - docker-compose.yml: Sin volúmenes de código, usa env_file - supervisord.conf: Incluye Apache, Discord bot y colas de procesos - apache.conf: Configuración de virtualhost con rewrite - .dockerignore: Excluye archivos innecesarios de la imagen - Eliminados archivos duplicados de supervisor - Creada carpeta database/ para init scripts - Telegram funciona vía webhook (no necesita supervisor)
This commit is contained in:
48
.dockerignore
Normal file
48
.dockerignore
Normal file
@@ -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
|
||||
0
database/.gitkeep
Normal file
0
database/.gitkeep
Normal file
@@ -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"]
|
||||
|
||||
33
docker/apache.conf
Normal file
33
docker/apache.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
<Directory /var/www/html>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
|
||||
# Permitir acceso a archivos estáticos
|
||||
<FilesMatch "\.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$">
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
</Directory>
|
||||
|
||||
# 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
|
||||
</VirtualHost>
|
||||
|
||||
# Configuración de PHP
|
||||
<IfModule mod_php.c>
|
||||
php_value upload_max_filesize 10M
|
||||
php_value post_max_size 10M
|
||||
php_value max_execution_time 300
|
||||
php_value max_input_time 300
|
||||
</IfModule>
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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]
|
||||
|
||||
0
galeria/.gitkeep
Normal file
0
galeria/.gitkeep
Normal file
0
logs/.gitkeep
Normal file
0
logs/.gitkeep
Normal file
Reference in New Issue
Block a user