diff --git a/server/entrypoint.sh b/server/entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..22ca37c3ba9b5710bdc552116fa07cc41479c09f --- /dev/null +++ b/server/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +echo "Running composer install..." +composer install --no-scripts --no-autoloader --no-interaction --optimize-autoloader + +# Wait for the database to be ready before running migrations +echo "Waiting for database connection..." +until nc -z -v -w30 db 3306; do + echo "Waiting for MySQL..." + sleep 5 +done + +echo "Running migrations..." +php bin/console doctrine:migrations:migrate --no-interaction + +echo "Loading fixtures..." +php bin/console doctrine:fixtures:load --no-interaction + +echo "Starting PHP-FPM..." +exec php-fpm diff --git a/server/symfony.dockerfile b/server/symfony.dockerfile index a773a2d1fcae79f1c8dcd817ab6a3bd468ad9ffc..5ed835071352e395eeeae2dc795a8b76e3c220eb 100644 --- a/server/symfony.dockerfile +++ b/server/symfony.dockerfile @@ -20,10 +20,9 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && # Copy existing application files to container COPY ./web_app /var/www -# Install Symfony dependencies -RUN composer install --no-scripts --no-autoloader && composer dump-autoload +# Copy entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh -# Set permissions -RUN chown -R www-data:www-data /var/www - -CMD ["php-fpm"] \ No newline at end of file +# Set entrypoint script +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file