Class "Faker\Factory" not found I have this Dockerfile
FROM php:8.2-apache
WORKDIR /var/www/html
# Install required packages and libraries
RUN apt-get update && apt-get install -y \
libicu-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
unzip zip \
libzip-dev \
zlib1g-dev \
python3 \
python3-pip \
python3-venv \
&& docker-php-ext-install gettext intl pdo_mysql gd zip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Enable Apache mod_rewrite for Laravel
RUN a2enmod rewrite
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy the entire Laravel application
COPY . /var/www/html
# Set environment variable for Composer
ENV COMPOSER_ALLOW_SUPERUSER=1
# added this to fix composer error, but did not worked
RUN composer update
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader
# Create a Python virtual environment and install dependencies
RUN python3 -m venv /var/www/html/venv
RUN /var/www/html/venv/bin/pip install --upgrade pip
COPY requirements.txt /var/www/html/requirements.txt
RUN /var/www/html/venv/bin/pip install -r requirements.txt
# Set permissions for Laravel
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && \
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# Run Laravel migrations and seeds
RUN php artisan migrate --seed
# Expose port 80 and start Apache
EXPOSE 80
CMD ["apache2-foreground"]
The image is failing to build for this error -
[stage-0 14/14] RUN php artisan migrate --seed:
0.865
0.865 WARN The SQLite database configured for this application does not exist: database/database.sqlite.
0.865
0.876 INFO Preparing database.
0.876
0.878 Creating migration table ...................................... 15.03ms DONE
0.894
0.908 INFO Running migrations.
0.908
0.908 0001_01_00_000000_create_roles_table .......................... 23.98ms DONE
0.939 0001_01_01_000000_create_users_table .......................... 45.38ms DONE
0.991 0001_01_01_000001_create_cache_table .......................... 15.82ms DONE
1.014 0001_01_01_000002_create_jobs_table ........................... 37.76ms DONE
1.058 2024_06_18_184150_create_personal_access_tokens_table ......... 23.03ms DONE
1.087 2024_06_18_185102_create_tags_table ............................ 7.58ms DONE
1.101 2024_06_18_191025_create_a_i_models_table ...................... 8.07ms DONE
1.118 2024_06_18_191215_create_a_i_models_tags_table ................. 7.39ms DONE
1.131 2024_07_03_193121_create_a_i_model_parameters_table ............ 7.98ms DONE
1.146 2024_07_19_215750_create_a_p_i_keys_table ..................... 22.00ms DONE
1.175
1.176
1.176 INFO Seeding database.
1.176
1.271
1.282 In DatabaseServiceProvider.php line 93:
1.282
1.282 Class "Faker\Factory" not found
1.282
1.282
------
Dockerfile:47
--------------------
45 |
46 | # Run Laravel migrations and seeds
47 | >>> RUN php artisan migrate --seed
48 |
49 | # Expose port 80 and start Apache
--------------------
ERROR: failed to solve: process "/bin/sh -c php artisan migrate --seed" did not complete successfully: exit code: 1
I am not even using "facker" for seeding.
Can anyone help me fix this error?
Thanks in advance.
Faker has nothing to do with it, your issue is that you don't have a database.sqlite file in your project.
WARN The SQLite database configured for this application does not exist: database/database.sqlite.
Make sure to run touch /var/www/html/database/database.sqlite before you try to migrate the database.
Mr. @Tray2 I think it was created on the process. Notice the migrations were successful.
The error occurred while seeding, I have tried with the "database.sqlite" present.
@Deadly_Smile This is the command that failed..
ERROR: failed to solve: process "/bin/sh -c php artisan migrate --seed" did not complete successfully: exit code: 1
So remove the --seed part and see if it works then, my guess is that it will still fail.
If it works, then check all the seeder files for missing imports.
Please sign in or create an account to participate in this conversation.