Dummy data seeder and Docker improvements
This commit is contained in:
parent
1255496d73
commit
c40b027f4c
|
@ -25,11 +25,22 @@ RUN apt-get update && apt-get install -y \
|
|||
libfreetype-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng-dev \
|
||||
zlib1g-dev \
|
||||
nano \
|
||||
iputils-ping \
|
||||
curl \
|
||||
build-essential \
|
||||
libssl-dev \
|
||||
libmariadb-dev-compat \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
&& pip3 install mysqlclient \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) gd
|
||||
&& docker-php-ext-install -j$(nproc) gd \
|
||||
&& docker-php-ext-install -j$(nproc) pdo_mysql
|
||||
|
||||
RUN pecl install redis-5.3.7 \
|
||||
RUN pecl install redis-6.0.2 \
|
||||
&& docker-php-ext-enable redis
|
||||
|
||||
# Use the default production configuration for PHP runtime arguments, see
|
||||
|
|
|
@ -15,7 +15,7 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->string('chat_id')->unique();
|
||||
$table->boolean('type_team_state')->default(true);
|
||||
$table->varchar('last_message_hash')->nullable();
|
||||
$table->string('last_message_hash')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class DummyDataSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$user = new User();
|
||||
$user->name = 'admin';
|
||||
$user->surname = 'User';
|
||||
$user->username = 'admin';
|
||||
$user->password = Hash::make('admin');
|
||||
$user->email = 'u1@example.com';
|
||||
$user->save();
|
||||
$user->addRole('superadmin');
|
||||
|
||||
/*
|
||||
Create 10 users:
|
||||
- 1 chief and with role 'admin'
|
||||
- other 2 chief and driver
|
||||
- other 2 chief
|
||||
- other 2 driver
|
||||
- other 3 normal user
|
||||
*/
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$user = new User();
|
||||
$user->name = ''.$i;
|
||||
$user->surname = 'User';
|
||||
$user->username = 'user' . $i;
|
||||
$user->password = Hash::make('user' . $i);
|
||||
$user->email = 'u' . $i+1 . '@example.com';
|
||||
$user->save();
|
||||
|
||||
if ($i === 1) {
|
||||
$user->addRole('admin');
|
||||
$user->update(['chief' => true]);
|
||||
} elseif ($i === 2 || $i === 3) {
|
||||
$user->addRole('chief');
|
||||
$user->update(['chief' => true, 'driver' => true]);
|
||||
} elseif ($i === 4 || $i === 5) {
|
||||
$user->addRole('chief');
|
||||
} elseif ($i === 6 || $i === 7) {
|
||||
$user->update(['driver' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,20 @@ else
|
|||
# Generate encryption key
|
||||
echo "Generating encryption key..."
|
||||
php artisan key:generate
|
||||
|
||||
# Run migrations
|
||||
echo "Running migrations..."
|
||||
php artisan migrate --force
|
||||
|
||||
# Run seeders
|
||||
echo "Running seeders..."
|
||||
php artisan db:seed
|
||||
php artisan db:seed --class=DummyDataSeeder
|
||||
fi
|
||||
|
||||
# Run migrations
|
||||
echo "Running migrations..."
|
||||
php artisan migrate
|
||||
|
||||
# Run Apache
|
||||
apache2-foreground
|
||||
|
|
|
@ -20,7 +20,8 @@ services:
|
|||
- UID=${UID:-1000}
|
||||
- GID=${GID:-1000}
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_USER=user
|
||||
|
@ -39,6 +40,10 @@ services:
|
|||
MYSQL_PASSWORD: password
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
|
||||
frontend:
|
||||
build:
|
||||
|
|
Loading…
Reference in New Issue