diff --git a/.env.example.docker b/.env.example.docker new file mode 100644 index 0000000..80125ed --- /dev/null +++ b/.env.example.docker @@ -0,0 +1,24 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_LOG_LEVEL=debug +APP_URL=http://localhost + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=db +DB_USERNAME=user +DB_PASSWORD=password + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +QUEUE_DRIVER=sync + +# Set the allowed domains for CORS. +# Separate each one by a comma. +# Remove or comment to allow all origins. + +CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:4200 \ No newline at end of file diff --git a/config/database.php b/config/database.php index a196943..a9ee9d8 100644 --- a/config/database.php +++ b/config/database.php @@ -52,6 +52,14 @@ 'prefix' => '', 'strict' => true, 'engine' => null, + 'modes' => [ + 'ONLY_FULL_GROUP_BY', + 'STRICT_TRANS_TABLES', + 'NO_ZERO_IN_DATE', + 'NO_ZERO_DATE', + 'ERROR_FOR_DIVISION_BY_ZERO', + 'NO_ENGINE_SUBSTITUTION', + ], ], 'pgsql' => [ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..651f3e1 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3.1' +services: + + php: + build: + context: ./php + volumes: + - ../:/app + working_dir: /app + ports: + - 8000:8000 + + mysql: + image: mysql + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: db + MYSQL_USER: user + MYSQL_PASSWORD: password \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 0000000..8d80916 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,3 @@ +FROM php:7.1-fpm + +RUN docker-php-ext-install pdo_mysql \ No newline at end of file diff --git a/readme.md b/readme.md index c76d8d0..4ceca41 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,7 @@ This repo is functionality complete — PRs and issues welcome! Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.4/installation#installation) +Alternative installation is possible without local dependencies relying on [Docker](#docker). Clone the repository @@ -78,6 +79,26 @@ Run the database seeder and you're done ***Note*** : It's recommended to have a clean database before seeding. You can refresh your migrations at any point to clean the database by running the following command php artisan migrate:refresh + +## Docker + +To install with [Docker](https://www.docker.com), run following commands: + +``` +git clone git@github.com:gothinkster/laravel-realworld-example-app.git +cd laravel-realworld-example-app +cp .env.example.docker .env +docker run -v $(pwd):/app composer install +cd ./docker +docker-compose up -d +docker-compose exec php php artisan key:generate +docker-compose exec php php artisan jwt:generate +docker-compose exec php php artisan migrate +docker-compose exec php php artisan db:seed +docker-compose exec php php artisan serve --host=0.0.0.0 +``` + +The api can be accessed at [http://localhost:8000/api](http://localhost:8000/api). ## API Specification