diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1d6ffa2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM php:7.2-cli-stretch + diff --git a/docker-compose-install.yml b/docker-compose-install.yml new file mode 100644 index 0000000..f9aeb1a --- /dev/null +++ b/docker-compose-install.yml @@ -0,0 +1,8 @@ +version: "2" +services: + web: + image: composer + working_dir: /var/www/html + volumes: + - ".:/var/www/html" + command: composer install diff --git a/docker-compose-run.yml b/docker-compose-run.yml new file mode 100644 index 0000000..56a17fe --- /dev/null +++ b/docker-compose-run.yml @@ -0,0 +1,17 @@ +version: "2" +services: + web: + image: nginx + ports: + - 5000:80 + working_dir: /var/www/html + volumes: + - ".:/var/www/html" + - ./docker/site.conf:/etc/nginx/conf.d/default.conf + depends_on: + - php + php: + image: php:7.2-fpm-stretch + working_dir: /var/www/html + volumes: + - ".:/var/www/html" \ No newline at end of file diff --git a/docker/site.conf b/docker/site.conf new file mode 100644 index 0000000..feb6f7e --- /dev/null +++ b/docker/site.conf @@ -0,0 +1,18 @@ +server { + listen 80; + index index.php index.html; + server_name web; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html; + + 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/index.php b/index.php index a512daf..1f43b9f 100644 --- a/index.php +++ b/index.php @@ -8,6 +8,15 @@ /** * Rotas da API */ +$app->get('/', function (Request $request, Response $response) use ($app) { + $response->getBody()->write("Root de Microservice!"); + return $response; +}); +$app->get('/bebe', function (Request $request, Response $response) use ($app) { + $response->getBody()->write("BebĂȘ de Microservice!"); + return $response; +}); + require 'routes.php'; $app->run(); \ No newline at end of file