mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 04:18:46 +08:00
Remove additional database connections and seeders in docker env
This commit is contained in:
parent
9357620d55
commit
b608bb8859
|
@ -1,31 +0,0 @@
|
|||
# Application key
|
||||
# Used for encryption where needed.
|
||||
# Run `php artisan key:generate` to generate a valid key.
|
||||
APP_KEY=SomeRandomString
|
||||
DEV_PORT=8080
|
||||
APP_ENV=development
|
||||
APP_DEBUG=true
|
||||
|
||||
# Application URL
|
||||
# Remove the hash below and set a URL if using BookStack behind
|
||||
# a proxy, if using a third-party authentication option.
|
||||
# This must be the root URL that you want to host BookStack on.
|
||||
# All URL's in BookStack will be generated using this value.
|
||||
#APP_URL=https://example.com
|
||||
|
||||
# Database details
|
||||
DB_CONNECTION=mysql_docker_dev
|
||||
|
||||
# Mail system to use
|
||||
# Can be 'smtp', 'mail' or 'sendmail'
|
||||
MAIL_DRIVER=smtp
|
||||
|
||||
# SMTP mail options
|
||||
MAIL_HOST=localhost
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
|
||||
# A full list of options can be found in the '.env.example.complete' file.
|
|
@ -92,18 +92,6 @@ return [
|
|||
'strict' => false,
|
||||
],
|
||||
|
||||
'mysql_docker_dev' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'db',
|
||||
'database' => 'bookstack-test',
|
||||
'username' => 'bookstack-test',
|
||||
'password' => 'bookstack-test',
|
||||
'charset' => 'utf8',
|
||||
'collation' => 'utf8_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => false,
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DummyContentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Create admin user
|
||||
$adminUser = new \BookStack\Auth\User();
|
||||
$adminUser->name = 'Admin User';
|
||||
$adminUser->email = 'admin@test.local';
|
||||
$adminUser->password = Hash::make('admin');
|
||||
$adminUser->email_confirmed = true;
|
||||
$adminUser->setRememberToken(str_random(10));
|
||||
$adminUser->save();
|
||||
$adminRole = \BookStack\Auth\Role::getRole('admin');
|
||||
$adminUser->attachRole($adminRole);
|
||||
|
||||
// Create an editor user
|
||||
$editorUser = factory(\BookStack\Auth\User::class)->create();
|
||||
$editorRole = \BookStack\Auth\Role::getRole('editor');
|
||||
$editorUser->attachRole($editorRole);
|
||||
|
||||
// Create a viewer user
|
||||
$viewerUser = factory(\BookStack\Auth\User::class)->create();
|
||||
$role = \BookStack\Auth\Role::getRole('viewer');
|
||||
$viewerUser->attachRole($role);
|
||||
|
||||
$byData = ['created_by' => $editorUser->id, 'updated_by' => $editorUser->id];
|
||||
|
||||
factory(\BookStack\Entities\Book::class, 5)->create($byData)
|
||||
->each(function($book) use ($editorUser, $byData) {
|
||||
$chapters = factory(\BookStack\Entities\Chapter::class, 3)->create($byData)
|
||||
->each(function($chapter) use ($editorUser, $book, $byData){
|
||||
$pages = factory(\BookStack\Entities\Page::class, 3)->make(array_merge($byData, ['book_id' => $book->id]));
|
||||
$chapter->pages()->saveMany($pages);
|
||||
});
|
||||
$pages = factory(\BookStack\Entities\Page::class, 3)->make($byData);
|
||||
$book->chapters()->saveMany($chapters);
|
||||
$book->pages()->saveMany($pages);
|
||||
});
|
||||
|
||||
$largeBook = factory(\BookStack\Entities\Book::class)->create(array_merge($byData, ['name' => 'Large book' . str_random(10)]));
|
||||
$pages = factory(\BookStack\Entities\Page::class, 200)->make($byData);
|
||||
$chapters = factory(\BookStack\Entities\Chapter::class, 50)->make($byData);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
|
||||
$shelves = factory(\BookStack\Entities\Bookshelf::class, 10)->create($byData);
|
||||
$largeBook->shelves()->attach($shelves->pluck('id'));
|
||||
|
||||
app(\BookStack\Auth\Permissions\PermissionService::class)->buildJointPermissions();
|
||||
app(\BookStack\Entities\SearchService::class)->indexAllEntities();
|
||||
}
|
||||
}
|
|
@ -21,6 +21,13 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: docker/dev/Dockerfile
|
||||
environment:
|
||||
DB_CONNECTION: mysql
|
||||
DB_HOST: db
|
||||
DB_PORT: 3306
|
||||
DB_DATABASE: bookstack-test
|
||||
DB_USER: bookstack-test
|
||||
DB_PASSWORD: bookstack-test
|
||||
ports:
|
||||
- ${DEV_PORT}:80
|
||||
volumes:
|
||||
|
|
|
@ -88,15 +88,11 @@ To get started, make sure you meet the following requirements:
|
|||
If all the conditions are met, you can proceed with the following steps:
|
||||
|
||||
1. Install Composer dependencies with **`docker-compose run app composer install`** (first time can take a while because the image has to be built)
|
||||
2. **Copy `.env.example.docker-development` to `.env`** and change `APP_KEY` to a random 32 char string
|
||||
2. **Copy `.env.example` to `.env`** and change `APP_KEY` to a random 32 char string
|
||||
3. Make sure **port 8080 is unused** *or else* change `DEV_PORT` to a free port on your host
|
||||
4. **Run `chgrp -R docker storage`**. The development container will chown the `storage` directory to the `www-data` user inside the container so BookStack can write to it. You need to change the group to your host's `docker` group here to not lose access to the `storage` directory
|
||||
5. **Run `docker-compose up`** and wait until all database migrations have been done
|
||||
6. **If you're starting the server for the first time**, seed the database in a separate terminal session:
|
||||
```php
|
||||
docker-compose exec app php artisan db:seed --class=DummyContentSeeder --database=mysql_docker_dev
|
||||
```
|
||||
7. You can now login with `admin@test.local` and `admin` as password on `localhost:8080` (or another port if specified)
|
||||
6. You can now login with `admin@admin.com` and `password` as password on `localhost:8080` (or another port if specified)
|
||||
|
||||
## Translations
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user