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 \
|
libfreetype-dev \
|
||||||
libjpeg62-turbo-dev \
|
libjpeg62-turbo-dev \
|
||||||
libpng-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/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
&& 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
|
&& docker-php-ext-enable redis
|
||||||
|
|
||||||
# Use the default production configuration for PHP runtime arguments, see
|
# Use the default production configuration for PHP runtime arguments, see
|
||||||
|
|
|
@ -15,7 +15,7 @@ return new class extends Migration
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('chat_id')->unique();
|
$table->string('chat_id')->unique();
|
||||||
$table->boolean('type_team_state')->default(true);
|
$table->boolean('type_team_state')->default(true);
|
||||||
$table->varchar('last_message_hash')->nullable();
|
$table->string('last_message_hash')->nullable();
|
||||||
$table->timestamps();
|
$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
|
# Generate encryption key
|
||||||
echo "Generating encryption key..."
|
echo "Generating encryption key..."
|
||||||
php artisan key:generate
|
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
|
fi
|
||||||
|
|
||||||
|
# Run migrations
|
||||||
|
echo "Running migrations..."
|
||||||
|
php artisan migrate
|
||||||
|
|
||||||
# Run Apache
|
# Run Apache
|
||||||
apache2-foreground
|
apache2-foreground
|
||||||
|
|
|
@ -20,7 +20,8 @@ services:
|
||||||
- UID=${UID:-1000}
|
- UID=${UID:-1000}
|
||||||
- GID=${GID:-1000}
|
- GID=${GID:-1000}
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
- DB_HOST=db
|
- DB_HOST=db
|
||||||
- DB_USER=user
|
- DB_USER=user
|
||||||
|
@ -39,6 +40,10 @@ services:
|
||||||
MYSQL_PASSWORD: password
|
MYSQL_PASSWORD: password
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/mysql
|
- db-data:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||||
|
timeout: 20s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
|
|
Loading…
Reference in New Issue