Update Dockerfile and Seeder
This commit is contained in:
parent
449964e2ff
commit
94c58daae3
|
@ -1,5 +1,5 @@
|
||||||
# Stage 1: Build PHP app and install dependencies
|
# Stage 1: Build PHP app and install dependencies
|
||||||
FROM php:8.2 AS builder
|
FROM php:8.3.4 AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
|
||||||
RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader
|
RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader
|
||||||
|
|
||||||
# Stage 2: Serve the application using Apache PHP
|
# Stage 2: Serve the application using Apache PHP
|
||||||
FROM php:8.1.10-apache
|
FROM php:8.3.4-apache
|
||||||
|
|
||||||
# Copy the built PHP app from the builder stage
|
# Copy the built PHP app from the builder stage
|
||||||
COPY --from=builder /app /var/www/html
|
COPY --from=builder /app /var/www/html
|
||||||
|
@ -34,7 +34,7 @@ RUN apt-get update && apt-get install -y \
|
||||||
libmariadb-dev-compat \
|
libmariadb-dev-compat \
|
||||||
python3-dev \
|
python3-dev \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
&& pip3 install mysqlclient \
|
&& pip3 install --break-system-packages 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 \
|
||||||
|
|
|
@ -24,6 +24,19 @@ class DummyDataSeeder extends Seeder
|
||||||
$user->addRole('superadmin');
|
$user->addRole('superadmin');
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
$names = [
|
||||||
|
['Mario', 'Rossi'],
|
||||||
|
['Luigi', 'Verdi'],
|
||||||
|
['Paolo', 'Bianchi'],
|
||||||
|
['Giovanni', 'Neri'],
|
||||||
|
['Giuseppe', 'Fontana'],
|
||||||
|
['Antonio', 'Gallo'],
|
||||||
|
['Francesco', 'Greco'],
|
||||||
|
['Angelo', 'Martini'],
|
||||||
|
['Vincenzo', 'Mancini'],
|
||||||
|
['Salvatore', 'Costa'],
|
||||||
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create 10 users:
|
Create 10 users:
|
||||||
- 1 chief and with role 'admin'
|
- 1 chief and with role 'admin'
|
||||||
|
@ -34,10 +47,10 @@ class DummyDataSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
for ($i = 1; $i <= 10; $i++) {
|
for ($i = 1; $i <= 10; $i++) {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->name = ''.$i;
|
$user->name = $names[$i-1][0];
|
||||||
$user->surname = 'User';
|
$user->surname = $names[$i-1][1];
|
||||||
$user->username = 'user' . $i;
|
$user->username = strtolower($user->surname.".".$user->name);
|
||||||
$user->password = Hash::make('user' . $i);
|
$user->password = Hash::make('password');
|
||||||
$user->email = 'u' . $i+1 . '@example.com';
|
$user->email = 'u' . $i+1 . '@example.com';
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,18 @@ else
|
||||||
sed -i "s/DB_DATABASE=laravel/DB_DATABASE=${DB_DATABASE}/g" .env.tmp
|
sed -i "s/DB_DATABASE=laravel/DB_DATABASE=${DB_DATABASE}/g" .env.tmp
|
||||||
sed -i "s/DB_USERNAME=root/DB_USERNAME=${DB_USER}/g" .env.tmp
|
sed -i "s/DB_USERNAME=root/DB_USERNAME=${DB_USER}/g" .env.tmp
|
||||||
sed -i "s/DB_PASSWORD=/DB_PASSWORD=${DB_PASSWORD}/g" .env.tmp
|
sed -i "s/DB_PASSWORD=/DB_PASSWORD=${DB_PASSWORD}/g" .env.tmp
|
||||||
|
|
||||||
|
# Set encryption key
|
||||||
|
echo "Generating encryption key..."
|
||||||
|
# We can't use just the command, so we need to save the output to a file and then overwrite it in .env.test
|
||||||
|
php artisan key:generate --show > key.tmp
|
||||||
|
sed -i "s#APP_KEY=#APP_KEY=$(cat key.tmp)#g" .env.tmp
|
||||||
|
rm key.tmp
|
||||||
|
|
||||||
|
# Overwrite .env with the updated .env.tmp
|
||||||
cat .env.tmp > .env
|
cat .env.tmp > .env
|
||||||
rm .env.tmp
|
rm .env.tmp
|
||||||
|
|
||||||
# Generate encryption key
|
|
||||||
echo "Generating encryption key..."
|
|
||||||
php artisan key:generate
|
|
||||||
|
|
||||||
# Run migrations
|
# Run migrations
|
||||||
echo "Running migrations..."
|
echo "Running migrations..."
|
||||||
php artisan migrate --force
|
php artisan migrate --force
|
||||||
|
|
|
@ -29,7 +29,6 @@ services:
|
||||||
- DB_DATABASE=mydb
|
- DB_DATABASE=mydb
|
||||||
volumes:
|
volumes:
|
||||||
- laravel-storage:/var/www/html/storage
|
- laravel-storage:/var/www/html/storage
|
||||||
- ./.env.docker:/var/www/html/.env
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
|
|
Loading…
Reference in New Issue