added development environment

This commit is contained in:
2022-04-18 13:22:09 +02:00
parent b960d5eefe
commit 844e3f3226
4 changed files with 55 additions and 0 deletions

7
PHP.Dockerfile Normal file
View File

@@ -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

8
app/public/index.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
$pdo = new PDO('mysql:dbname=tutorial;host=mysql', 'grisu', 'secret', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$query = $pdo->query('SHOW VARIABLES like "version"');
$row = $query->fetch();
echo 'MySQL version:' . $row['Value'];

28
docker-compose.yml Normal file
View File

@@ -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: {}

12
nginx.conf Normal file
View File

@@ -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;
}
}