added wait for mysql to start in docker

fix role not found on register/login
This commit is contained in:
jack
2018-05-14 12:45:30 +08:00
parent d5694be293
commit 06aa931eb5
10 changed files with 243 additions and 251 deletions
+5 -1
View File
@@ -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
@@ -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;
}
}
-1
View File
@@ -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
{
Generated
+149 -241
View File
@@ -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",
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->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');
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
+1 -1
View File
@@ -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:
-2
View File
@@ -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
+10
View File
@@ -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"