From a4c7a3b51d8ae6a656791a41f75156b58a564d3a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 17 Jan 2023 09:10:21 +0100 Subject: [PATCH] Update the docker configuration with an improveed one (WIP) --- docker-compose.yml | 44 ++++++++++++++++++++++++++++ docker/docker-compose.yml | 21 ------------- docker/nginx/nginx.conf | 32 ++++++++++++++++++++ docker/php-fpm/Dockerfile | 15 ++++++++++ docker/php-fpm/php-ini-overrides.ini | 4 +++ docker/server/Dockerfile | 17 ----------- docker/server/php.ini | 6 ---- 7 files changed, 95 insertions(+), 44 deletions(-) create mode 100644 docker-compose.yml delete mode 100644 docker/docker-compose.yml create mode 100644 docker/nginx/nginx.conf create mode 100644 docker/php-fpm/Dockerfile create mode 100644 docker/php-fpm/php-ini-overrides.ini delete mode 100644 docker/server/Dockerfile delete mode 100644 docker/server/php.ini diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..a3ae26f0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3.1' +services: + php-fpm: + build: docker/php-fpm + working_dir: /var/www/html + extra_hosts: + - host.docker.internal:host-gateway + volumes: + - '.:/var/www/html' + - './docker/php-fpm/php-ini-overrides.ini:/etc/php/8.0/fpm/conf.d/99-overrides.ini' + + webserver: + image: 'nginx:alpine' + working_dir: /var/www/html + volumes: + - '.:/var/www/html' + - './docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf' + ports: + - '3000:80' + + mysql: + image: 'mysql:8.0' + volumes: + - './docker/mysql:/var/lib/mysql' + environment: + - MYSQL_ROOT_PASSWORD=secret + - MYSQL_DATABASE=easyappointments + - MYSQL_USER=easyappointments + - MYSQL_PASSWORD=secret + ports: + - '3001:3306' + + phpmyadmin: + image: phpmyadmin + restart: always + ports: + - '3002:80' + environment: + - 'PMA_ARBITRARY=1' + + mailhog: + image: 'mailhog/mailhog:latest' + ports: + - '3003:8025' diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index c03d1f62..00000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3.1" -services: - mysql: - image: mysql:5.7 - container_name: easyappointments-database - volumes: - - ./mysql:/var/lib/mysql - environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_DATABASE=easyappointments - ports: - - "8001:3306" - server: - build: ./server - image: easyappointments-server:v1 - container_name: easyappointments-server - ports: - - "8000:80" - volumes: - - ../:/var/www/html - - ./server/php.ini:/usr/local/etc/php/conf.d/99-overrides.ini diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 00000000..25c4dc82 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,32 @@ +server { + listen 80 default; + + server_name localhost; + + client_max_body_size 108M; + + access_log /var/log/nginx/application.access.log; + + root /var/www/html/.; + + index index.php; + + # try to serve file directly, fallback to index.php + location / { + try_files $uri /index.php$is_args$args; + } + + if (!-e $request_filename) { + rewrite ^.*$ /index.php last; + } + + location ~ \.php$ { + fastcgi_pass php-fpm:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log"; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + include fastcgi_params; + } +} diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile new file mode 100644 index 00000000..6754d317 --- /dev/null +++ b/docker/php-fpm/Dockerfile @@ -0,0 +1,15 @@ +FROM phpdockerio/php:8.0-fpm +WORKDIR "/var/www/html" + +RUN apt-get update; \ + apt-get -y --no-install-recommends install \ + git \ + php8.0-gd \ + php8.0-intl \ + php8.0-ldap \ + php8.0-mcrypt \ + php8.0-mysql \ + php8.0-soap \ + php8.0-xdebug; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* diff --git a/docker/php-fpm/php-ini-overrides.ini b/docker/php-fpm/php-ini-overrides.ini new file mode 100644 index 00000000..a5e2d796 --- /dev/null +++ b/docker/php-fpm/php-ini-overrides.ini @@ -0,0 +1,4 @@ +upload_max_filesize = 100M +post_max_size = 108M +xdebug.mode = debug +xdebug.client_host = host.docker.internal diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile deleted file mode 100644 index b5ef938e..00000000 --- a/docker/server/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM php:7.4-apache - -WORKDIR "/var/www/html" - -ARG DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && apt-get install -y \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libpng-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && docker-php-ext-install -j$(nproc) gd gettext mysqli pdo_mysql - -RUN pecl install xdebug \ - && docker-php-ext-enable xdebug - -RUN a2enmod rewrite diff --git a/docker/server/php.ini b/docker/server/php.ini deleted file mode 100644 index 65fd1967..00000000 --- a/docker/server/php.ini +++ /dev/null @@ -1,6 +0,0 @@ -date.timezone = UTC -upload_max_filesize = 100M -post_max_size = 100M -xdebug.remote_enable = on -xdebug.remote_host = host.docker.internal -max_execution_time = 0