From 4338cd51bdb819f7da2d35e13b14b8e72ef7c30a Mon Sep 17 00:00:00 2001 From: Felipe Aquino Date: Thu, 5 Feb 2026 13:29:37 -0300 Subject: [PATCH] laravel_base --- docker-compose.yml | 43 +++++++++++++++++++++++++++ nginx/default.conf | 22 ++++++++++++++ php/Dockerfile | 73 ++++++++++++++++++++++++++++++++++++++++++++++ supervisord.conf | 40 +++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 docker-compose.yml create mode 100644 nginx/default.conf create mode 100644 php/Dockerfile create mode 100644 supervisord.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3e61c9f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,43 @@ +version: "3.9" + +services: + php: + build: + context: . + dockerfile: php/Dockerfile + restart: always + depends_on: + - mysql + volumes: + - eap:/eap + environment: + DB_HOST: mysql + DB_PORT: 3306 + DB_DATABASE: eap + DB_USERNAME: eap + DB_PASSWORD: eap123 + + nginx: + image: nginx:alpine + restart: always + depends_on: + - php + volumes: + - eap:/eap + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + + mysql: + image: mysql:8.0 + restart: always + command: --default-authentication-plugin=mysql_native_password + environment: + MYSQL_ROOT_PASSWORD: root123 + MYSQL_DATABASE: eap + MYSQL_USER: eap + MYSQL_PASSWORD: eap123 + volumes: + - mysql-data:/var/lib/mysql + +volumes: + mysql-data: + eap: diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..a96c034 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + + root /eap/public; + index index.php index.html; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ /\. { + deny all; + } +} diff --git a/php/Dockerfile b/php/Dockerfile new file mode 100644 index 0000000..99fbc8a --- /dev/null +++ b/php/Dockerfile @@ -0,0 +1,73 @@ +FROM php:8.3-fpm + +# ----------------------------- +# Dependências do sistema +# ----------------------------- +RUN apt-get update && apt-get install -y \ + git \ + curl \ + unzip \ + supervisor \ + redis-server \ + libpng-dev \ + libjpeg-dev \ + libfreetype6-dev \ + libonig-dev \ + libxml2-dev \ + libzip-dev \ + zip \ + npm \ + && rm -rf /var/lib/apt/lists/* + +# ----------------------------- +# Extensões PHP +# ----------------------------- +RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install \ + pdo \ + pdo_mysql \ + mbstring \ + exif \ + pcntl \ + bcmath \ + gd \ + zip \ + sockets + +# ----------------------------- +# Redis PHP extension +# ----------------------------- +RUN pecl install redis \ + && docker-php-ext-enable redis + +# ----------------------------- +# Composer +# ----------------------------- +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# ----------------------------- +# Diretórios necessários +# ----------------------------- +RUN mkdir -p /var/log/supervisor \ + /var/run/supervisor + +# ----------------------------- +# Diretório da aplicação +# ----------------------------- +WORKDIR /eap + + +# ----------------------------- +# Supervisor config +# ----------------------------- +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# ----------------------------- +# Expor PHP-FPM +# ----------------------------- +EXPOSE 9000 + +# ----------------------------- +# Inicialização +# ----------------------------- +CMD ["/usr/bin/supervisord", "-n"] diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..29fbfb0 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,40 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisor/supervisord.log +pidfile=/var/run/supervisord.pid + +; ============================ +; Redis +; ============================ +[program:redis] +command=/usr/bin/redis-server --bind 127.0.0.1 --protected-mode no +priority=5 +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/redis.out.log +stderr_logfile=/var/log/supervisor/redis.err.log +startsecs=3 + +; ============================ +; PHP-FPM +; ============================ +[program:php-fpm] +command=/usr/local/sbin/php-fpm -F +priority=10 +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/php-fpm.out.log +stderr_logfile=/var/log/supervisor/php-fpm.err.log + +; ============================ +; Horizon +; ============================ +[program:horizon] +command=php /eap/artisan horizon +directory=/eap +user=www-data +priority=20 +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/horizon.out.log +stderr_logfile=/var/log/supervisor/horizon.err.log