diff --git a/.env b/.env new file mode 100644 index 0000000..5bdf2a4 --- /dev/null +++ b/.env @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Nginx +NGINX_HOST=localhost + +# PHP +PHP_VERSION=7 + +# MySQL +MYSQL_VERSION=5.7.22 +MYSQL_HOST=mysql +MYSQL_DATABASE=test +MYSQL_ROOT_USER=root +MYSQL_ROOT_PASSWORD=root +MYSQL_USER=dev +MYSQL_PASSWORD=dev diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5491845 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,56 @@ +version: '3' +services: + web: + image: nginx:latest + container_name: dock_nginx + volumes: + - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf" + - "./etc/ssl:/etc/ssl" + - "./www:/var/www/html/public" + - "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template" + ports: + - "8080:80" + - "3000:443" + environment: + - NGINX_HOST=${NGINX_HOST} + command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" + restart: always + depends_on: + - php + - mysql + + php: + image: php:${PHP_VERSION}-fpm + container_name: dock_php + restart: always + volumes: + - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini" + - "./www:/var/www/html/public" + + mysql: + image: mysql:${MYSQL_VERSION} + container_name: dock_mysql + restart: always + env_file: + - ".env" + environment: + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + ports: + - "8989:3306" + volumes: + - "./data/db/mysql:/var/lib/mysql" + + myadmin: + image: phpmyadmin/phpmyadmin + container_name: dock_phpmyadmin + ports: + - "8081:80" + environment: + - PMA_ARBITRARY=1 + - PMA_HOST=${MYSQL_HOST} + restart: always + depends_on: + - mysql diff --git a/etc/nginx/default.conf b/etc/nginx/default.conf new file mode 100644 index 0000000..1088f8f --- /dev/null +++ b/etc/nginx/default.conf @@ -0,0 +1,48 @@ +# Nginx configuration + +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name localhost; + + index index.php index.html; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html/public; + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} + +# server { +# server_name localhost; + +# listen 443 ssl; +# fastcgi_param HTTPS on; + +# ssl_certificate /etc/ssl/server.pem; +# ssl_certificate_key /etc/ssl/server.key; +# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; + +# index index.php index.html; +# error_log /var/log/nginx/error.log; +# access_log /var/log/nginx/access.log; +# root /var/www/html/public; + +# location ~ \.php$ { +# try_files $uri =404; +# fastcgi_split_path_info ^(.+\.php)(/.+)$; +# fastcgi_pass php:9000; +# fastcgi_index index.php; +# include fastcgi_params; +# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +# fastcgi_param PATH_INFO $fastcgi_path_info; +# } +# } \ No newline at end of file diff --git a/etc/nginx/default.template.conf b/etc/nginx/default.template.conf new file mode 100644 index 0000000..2a48589 --- /dev/null +++ b/etc/nginx/default.template.conf @@ -0,0 +1,48 @@ +# Nginx configuration + +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name ${NGINX_HOST}; + + index index.php index.html; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html/public; + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} + +# server { +# server_name ${NGINX_HOST}; + +# listen 443 ssl; +# fastcgi_param HTTPS on; + +# ssl_certificate /etc/ssl/server.pem; +# ssl_certificate_key /etc/ssl/server.key; +# ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; + +# index index.php index.html; +# error_log /var/log/nginx/error.log; +# access_log /var/log/nginx/access.log; +# root /var/www/html/public; + +# location ~ \.php$ { +# try_files $uri =404; +# fastcgi_split_path_info ^(.+\.php)(/.+)$; +# fastcgi_pass php:9000; +# fastcgi_index index.php; +# include fastcgi_params; +# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +# fastcgi_param PATH_INFO $fastcgi_path_info; +# } +# } \ No newline at end of file diff --git a/etc/php/php.ini b/etc/php/php.ini new file mode 100644 index 0000000..4f47c01 --- /dev/null +++ b/etc/php/php.ini @@ -0,0 +1,29 @@ +; PHP Configuration + +;[Date] +; Defines the default timezone used by the date functions +; http://php.net/date.timezone +;date.timezone = + +; Error handling +;display_errors = Off + +; Xdebug +; See https://xdebug.org/docs/all_settings + +;PHPStorm +[Xdebug] +xdebug.remote_enable=1 +xdebug.idekey=PHPSTORM +xdebug.profiler_enable=0 +xdebug.max_nesting_level=700 +xdebug.remote_host=192.168.0.1 # your ip +xdebug.remote_port=9000 + +;Netbeans +;[Xdebug] +;xdebug.remote_enable=1 +;xdebug.remote_handler=dbgp +;xdebug.remote_mode=req +;xdebug.remote_host=192.168.0.1 # your ip +;xdebug.remote_port=9000 \ No newline at end of file diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..f395d2c --- /dev/null +++ b/www/index.php @@ -0,0 +1,10 @@ + + + + + Docker + + + + +