├── Dockerfile ├── docker-compose.yml ├── public └── index.php ├── readme.md ├── src └── .gitkeep ├── tests └── .gitkeep └── webserver └── nginx.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-fpm 2 | RUN docker-php-ext-install pdo_mysql 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | services: 3 | nginx: 4 | image: nginx:1.17.3 5 | container_name: nginx 6 | ports: 7 | - "8080:80" 8 | volumes: 9 | - ".:/var/www/html/" 10 | - "./webserver/nginx.conf:/etc/nginx/nginx.conf" 11 | links: 12 | - php 13 | - mysql 14 | php: 15 | build: 16 | context: . 17 | image: phpdocker 18 | container_name: php 19 | ports: 20 | - "9000:9000" 21 | volumes: 22 | - ".:/var/www/html/" 23 | # command: php -S 0.0.0.0:9000 -t public/ 24 | # links: 25 | # - mysql 26 | mysql: 27 | image: mysql:5.7 28 | container_name: mysql 29 | ports: 30 | - "3307:3306" 31 | volumes: 32 | - mysql:/var/lib/mysql/ 33 | environment: 34 | MYSQL_DATABASE: 'database' 35 | MYSQL_USER: 'root' 36 | MYSQL_PASSWORD: '12345678' 37 | MYSQL_ROOT_PASSWORD: '12345' 38 | volumes: 39 | mysql: 40 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | getMessage(); 9 | die(); 10 | } 11 | 12 | var_dump($pdo); 13 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Docker Tutorial 2 | 3 | ### Projeto utilizado na série de artigos "Criando um ambiente de desenvolvimento PHP mínimo com Docker" 4 | 5 | https://blog.lafraga.me/2019/09/11/criando-um-ambiente-de-desenvolvimento-php-minimo-com-docker-pt-1/ 6 | https://blog.lafraga.me/2019/09/11/criando-um-ambiente-de-desenvolvimento-php-minimo-com-docker-pt-2/ 7 | https://blog.lafraga.me/2019/09/11/criando-um-ambiente-de-desenvolvimento-php-minimo-com-docker-pt-3/ 8 | -------------------------------------------------------------------------------- /src/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lafraga93/docker-tutorial/17dbc4741915232682248cf5e77a8c6413a97504/src/.gitkeep -------------------------------------------------------------------------------- /tests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lafraga93/docker-tutorial/17dbc4741915232682248cf5e77a8c6413a97504/tests/.gitkeep -------------------------------------------------------------------------------- /webserver/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | error_log /var/log/nginx/error.log warn; 5 | pid /var/run/nginx.pid; 6 | 7 | events { 8 | worker_connections 1024; 9 | } 10 | 11 | http { 12 | 13 | include /etc/nginx/mime.types; 14 | default_type application/octet-stream; 15 | 16 | log_format main '$remote_addr - $remote_user [$time_local] "$request"' 17 | '$status $body_bytes_sent "$http_referer"' 18 | '"$http_user_agent" "$http_x_forwarded_for"'; 19 | 20 | access_log /var/log/nginx/access.log main; 21 | 22 | sendfile on; 23 | 24 | keepalive_timeout 65; 25 | 26 | server { 27 | 28 | listen 80; 29 | server_name localhost; 30 | root /var/www/html/public/; 31 | autoindex on; 32 | index index.php; 33 | 34 | location / { 35 | 36 | try_files $uri $uri/ /index.php; 37 | 38 | location = /index.php { 39 | 40 | fastcgi_pass php:9000; 41 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 | include fastcgi_params; 43 | 44 | } 45 | 46 | } 47 | 48 | location ~ \.php$ { 49 | return 444; 50 | } 51 | 52 | } 53 | } 54 | --------------------------------------------------------------------------------