From 844e3f3226250208c978e3787d5ad1c9445c4522 Mon Sep 17 00:00:00 2001 From: Grisu Date: Mon, 18 Apr 2022 13:22:09 +0200 Subject: [PATCH] added development environment --- PHP.Dockerfile | 7 +++++++ app/public/index.php | 8 ++++++++ docker-compose.yml | 28 ++++++++++++++++++++++++++++ nginx.conf | 12 ++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 PHP.Dockerfile create mode 100644 app/public/index.php create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/PHP.Dockerfile b/PHP.Dockerfile new file mode 100644 index 0000000..dda2cf7 --- /dev/null +++ b/PHP.Dockerfile @@ -0,0 +1,7 @@ +FROM php:fpm + +# install pdo mysql extension +RUN docker-php-ext-install pdo pdo_mysql + +# install xdebug for php +RUN pecl install xdebug && docker-php-ext-enable xdebug \ No newline at end of file diff --git a/app/public/index.php b/app/public/index.php new file mode 100644 index 0000000..0394e41 --- /dev/null +++ b/app/public/index.php @@ -0,0 +1,8 @@ + PDO::ERRMODE_EXCEPTION]); + +$query = $pdo->query('SHOW VARIABLES like "version"'); + +$row = $query->fetch(); + +echo 'MySQL version:' . $row['Value']; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f0198da --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3' +services: + web: + image: nginx:latest + ports: + - "80:80" + volumes: + - ./nginx.conf:/etc/nginx/conf.d/nginx.conf + - ./app:/app + php: + build: + context: . + dockerfile: PHP.Dockerfile + volumes: + - ./app:/app + mysql: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: 'secret' + MYSQL_USER: 'grisu' + MYSQL_PASSWORD: 'secret' + MYSQL_DATABASE: 'tutorial' + volumes: + - mysqldata:/var/lib/mysql + ports: + - 3306:3306 +volumes: + mysqldata: {} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..efcbb96 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,12 @@ +server { + listen 80 default_server; + root /app/public; + + index index.php index.html index.htm; + + location ~ \.php$ { + fastcgi_pass php:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} \ No newline at end of file