From 06aa931eb57dbc7c95748ade6e3bb659f0659abe Mon Sep 17 00:00:00 2001 From: jack Date: Mon, 14 May 2018 12:45:30 +0800 Subject: [PATCH] added wait for mysql to start in docker fix role not found on register/login --- Dockerfile | 6 +- .../Controllers/Auth/RegisterController.php | 16 +- app/Providers/AppServiceProvider.php | 1 - composer.lock | 390 +++++++----------- .../2014_10_12_000000_create_users_table.php | 35 ++ ...12_100000_create_password_resets_table.php | 32 ++ docker-compose.yml | 2 +- docker/mysql/Dockerfile | 2 - resources/assets/js/pages/settings/rate.vue | 0 wait.sh | 10 + 10 files changed, 243 insertions(+), 251 deletions(-) create mode 100644 database/migrations/2014_10_12_000000_create_users_table.php create mode 100644 database/migrations/2014_10_12_100000_create_password_resets_table.php create mode 100644 resources/assets/js/pages/settings/rate.vue create mode 100644 wait.sh diff --git a/Dockerfile b/Dockerfile index 74d27249..a6a73f12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,9 @@ RUN docker-php-ext-install pdo pdo_mysql zip WORKDIR /app COPY . /app RUN composer install -CMD php artisan serve --host=0.0.0.0 --port=8000 + +COPY wait.sh /usr/local/bin/wait.sh +RUN chmod +x /usr/local/bin/wait.sh + +CMD /usr/local/bin/wait.sh && php artisan serve --host=0.0.0.0 --port=8000 EXPOSE 8000 diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index b3c1d95f..ecfc4151 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Auth; use App\User; +use App\Role; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; @@ -57,10 +58,15 @@ class RegisterController extends Controller */ protected function create(array $data) { - return User::create([ - 'name' => $data['name'], - 'email' => $data['email'], - 'password' => bcrypt($data['password']), - ]); + $role = Role::where('name','=','member')->first(); + $user = new User(); + $user->name = $data['name']; + $user->email = $data['email']; + $user->password = bcrypt($data['password']); + $user->save(); + $user->attachRole($role); + + return $user; + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 33e0985a..f3f0d65a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,7 +5,6 @@ namespace App\Providers; use Laravel\Dusk\DuskServiceProvider; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Facades\Schema; class AppServiceProvider extends ServiceProvider { diff --git a/composer.lock b/composer.lock index f8e05bc5..fa74a2f6 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "bbcc333ace48de3a56664e9bf1182b6d", + "content-hash": "be0b3eae101bbe8134154fd539fdafaa", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -367,30 +367,6 @@ "time": "2018-02-07T20:20:57+00:00" }, { -<<<<<<< HEAD - "name": "guzzlehttp/psr7", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" -======= "name": "guzzlehttp/guzzle", "version": "6.3.3", "source": { @@ -474,7 +450,6 @@ }, "require-dev": { "phpunit/phpunit": "^4.0" ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 }, "type": "library", "extra": { @@ -484,11 +459,7 @@ }, "autoload": { "psr-4": { -<<<<<<< HEAD - "GuzzleHttp\\Psr7\\": "src/" -======= "GuzzleHttp\\Promise\\": "src/" ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 }, "files": [ "src/functions_include.php" @@ -503,7 +474,61 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" -<<<<<<< HEAD + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" }, { "name": "Tobias Schultze", @@ -549,44 +574,10 @@ "ext-gd": "to use GD library based image processing.", "ext-imagick": "to use Imagick based image processing.", "intervention/imagecache": "Caching extension for the Intervention Image library" -======= - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 }, "type": "library", "extra": { "branch-alias": { -<<<<<<< HEAD "dev-master": "2.3-dev" }, "laravel": { @@ -596,23 +587,12 @@ "aliases": { "Image": "Intervention\\Image\\Facades\\Image" } -======= - "dev-master": "1.4-dev" ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 } }, "autoload": { "psr-4": { -<<<<<<< HEAD "Intervention\\Image\\": "src/Intervention/Image" } -======= - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -620,7 +600,6 @@ ], "authors": [ { -<<<<<<< HEAD "name": "Oliver Vogel", "email": "oliver@olivervogel.com", "homepage": "http://olivervogel.com/" @@ -637,28 +616,6 @@ "watermark" ], "time": "2017-09-21T16:29:17+00:00" -======= - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2017-03-20T17:10:46+00:00" ->>>>>>> 4278419aaa489ca2ba12cdcdffdfc53e549ed1f1 }, { "name": "jakub-onderka/php-console-color", @@ -749,16 +706,16 @@ }, { "name": "laravel/framework", - "version": "v5.6.20", + "version": "v5.6.21", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c" + "reference": "458a89b1c5ff73072c27308566f444c790f76f28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c", - "reference": "3c11e7acc6ad14dd86e2f9e4bf3230010c3e611c", + "url": "https://api.github.com/repos/laravel/framework/zipball/458a89b1c5ff73072c27308566f444c790f76f28", + "reference": "458a89b1c5ff73072c27308566f444c790f76f28", "shasum": "" }, "require": { @@ -884,20 +841,20 @@ "framework", "laravel" ], - "time": "2018-05-02T15:22:18+00:00" + "time": "2018-05-08T13:30:15+00:00" }, { "name": "laravel/socialite", - "version": "v3.0.9", + "version": "v3.0.11", "source": { "type": "git", "url": "https://github.com/laravel/socialite.git", - "reference": "fc1c8d415699e502f3e61cbc61e3250d5bd942eb" + "reference": "4d29ba66fdb38ec994b778e5e51657555cc10511" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/socialite/zipball/fc1c8d415699e502f3e61cbc61e3250d5bd942eb", - "reference": "fc1c8d415699e502f3e61cbc61e3250d5bd942eb", + "url": "https://api.github.com/repos/laravel/socialite/zipball/4d29ba66fdb38ec994b778e5e51657555cc10511", + "reference": "4d29ba66fdb38ec994b778e5e51657555cc10511", "shasum": "" }, "require": { @@ -946,7 +903,7 @@ "laravel", "oauth" ], - "time": "2017-11-06T16:02:48+00:00" + "time": "2018-05-12T17:44:53+00:00" }, { "name": "laravel/tinker", @@ -1011,6 +968,74 @@ ], "time": "2018-04-16T12:10:37+00:00" }, + { + "name": "laravelcollective/html", + "version": "v5.6.8", + "source": { + "type": "git", + "url": "https://github.com/LaravelCollective/html.git", + "reference": "42c0854e00d6bb3346883d122b444fbf15a13ecb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/LaravelCollective/html/zipball/42c0854e00d6bb3346883d122b444fbf15a13ecb", + "reference": "42c0854e00d6bb3346883d122b444fbf15a13ecb", + "shasum": "" + }, + "require": { + "illuminate/http": "5.6.*", + "illuminate/routing": "5.6.*", + "illuminate/session": "5.6.*", + "illuminate/support": "5.6.*", + "illuminate/view": "5.6.*", + "php": ">=7.1.3" + }, + "require-dev": { + "illuminate/database": "5.6.*", + "mockery/mockery": "~1.0", + "phpunit/phpunit": "~7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.6-dev" + }, + "laravel": { + "providers": [ + "Collective\\Html\\HtmlServiceProvider" + ], + "aliases": { + "Form": "Collective\\Html\\FormFacade", + "Html": "Collective\\Html\\HtmlFacade" + } + } + }, + "autoload": { + "psr-4": { + "Collective\\Html\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + }, + { + "name": "Adam Engebretson", + "email": "adam@laravelcollective.com" + } + ], + "description": "HTML and Form Builders for the Laravel Framework", + "homepage": "https://laravelcollective.com", + "time": "2018-05-10T17:15:15+00:00" + }, { "name": "lcobucci/jwt", "version": "3.2.2", @@ -1069,86 +1094,18 @@ ], "time": "2017-09-01T08:23:26+00:00" }, - { - "name": "laravelcollective/html", - "version": "v5.6.6", - "source": { - "type": "git", - "url": "https://github.com/LaravelCollective/html.git", - "reference": "b3a10245c791a211e5f8ec37117f4549cd22aabe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/LaravelCollective/html/zipball/b3a10245c791a211e5f8ec37117f4549cd22aabe", - "reference": "b3a10245c791a211e5f8ec37117f4549cd22aabe", - "shasum": "" - }, - "require": { - "illuminate/http": "5.6.*", - "illuminate/routing": "5.6.*", - "illuminate/session": "5.6.*", - "illuminate/support": "5.6.*", - "illuminate/view": "5.6.*", - "php": ">=7.1.3" - }, - "require-dev": { - "illuminate/database": "5.6.*", - "mockery/mockery": "~1.0", - "phpunit/phpunit": "~5.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.6-dev" - }, - "laravel": { - "providers": [ - "Collective\\Html\\HtmlServiceProvider" - ], - "aliases": { - "Form": "Collective\\Html\\FormFacade", - "Html": "Collective\\Html\\HtmlFacade" - } - } - }, - "autoload": { - "psr-4": { - "Collective\\Html\\": "src/" - }, - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - }, - { - "name": "Adam Engebretson", - "email": "adam@laravelcollective.com" - } - ], - "description": "HTML and Form Builders for the Laravel Framework", - "homepage": "https://laravelcollective.com", - "time": "2018-04-09T14:09:32+00:00" - }, { "name": "league/flysystem", - "version": "1.0.44", + "version": "1.0.45", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "168dbe519737221dc87d17385cde33073881fd02" + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/168dbe519737221dc87d17385cde33073881fd02", - "reference": "168dbe519737221dc87d17385cde33073881fd02", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a99f94e63b512d75f851b181afcdf0ee9ebef7e6", + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6", "shasum": "" }, "require": { @@ -1219,7 +1176,7 @@ "sftp", "storage" ], - "time": "2018-04-06T09:58:14+00:00" + "time": "2018-05-07T08:44:23+00:00" }, { "name": "league/oauth1-client", @@ -1676,56 +1633,6 @@ ], "time": "2016-08-06T14:39:51+00:00" }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, { "name": "psr/log", "version": "1.0.2", @@ -3525,16 +3432,16 @@ }, { "name": "mockery/mockery", - "version": "1.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38" + "reference": "99e29d3596b16dabe4982548527d5ddf90232e99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/1bac8c362b12f522fdd1f1fa3556284c91affa38", - "reference": "1bac8c362b12f522fdd1f1fa3556284c91affa38", + "url": "https://api.github.com/repos/mockery/mockery/zipball/99e29d3596b16dabe4982548527d5ddf90232e99", + "reference": "99e29d3596b16dabe4982548527d5ddf90232e99", "shasum": "" }, "require": { @@ -3543,7 +3450,8 @@ "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "~5.7|~6.1" + "phpdocumentor/phpdocumentor": "^2.9", + "phpunit/phpunit": "~5.7.10|~6.5" }, "type": "library", "extra": { @@ -3572,8 +3480,8 @@ "homepage": "http://davedevelopment.co.uk" } ], - "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "http://github.com/mockery/mockery", + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", "keywords": [ "BDD", "TDD", @@ -3586,7 +3494,7 @@ "test double", "testing" ], - "time": "2017-10-06T16:20:43+00:00" + "time": "2018-05-08T08:54:48+00:00" }, { "name": "myclabs/deep-copy", diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php new file mode 100644 index 00000000..689cbeea --- /dev/null +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('name'); + $table->string('email')->unique(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } +} diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php new file mode 100644 index 00000000..0d5cb845 --- /dev/null +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -0,0 +1,32 @@ +string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('password_resets'); + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 1def6b57..e7aa352c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - .:/app env_file: .env working_dir: /app - command: bash -c 'php artisan migrate && php artisan serve --host 0.0.0.0' + command: bash -c 'sh /usr/local/bin/wait.sh && php artisan migrate && php artisan db:seed && php artisan serve --host 0.0.0.0' depends_on: - mysql links: diff --git a/docker/mysql/Dockerfile b/docker/mysql/Dockerfile index a3de8863..f8cba3da 100644 --- a/docker/mysql/Dockerfile +++ b/docker/mysql/Dockerfile @@ -15,6 +15,4 @@ RUN chown -R mysql:root /var/lib/mysql/ COPY my.cnf /etc/mysql/conf.d/my.cnf -CMD ["mysqld"] - EXPOSE 3306 diff --git a/resources/assets/js/pages/settings/rate.vue b/resources/assets/js/pages/settings/rate.vue new file mode 100644 index 00000000..e69de29b diff --git a/wait.sh b/wait.sh new file mode 100644 index 00000000..ee7909a3 --- /dev/null +++ b/wait.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Waiting for mysql" +until mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" &> /dev/null +do + printf "." + sleep 1 +done + +echo -e "\nmysql ready"