add entrypoint to dockerfile

This commit is contained in:
David Igón
2025-03-06 12:53:32 +01:00
parent 7fca48d2c2
commit f2816803da
2 changed files with 26 additions and 0 deletions
+5
View File
@@ -54,4 +54,9 @@ RUN composer install --prefer-dist --no-scripts --no-dev --optimize-autoloader
EXPOSE 9000
COPY entrypoint.sh /usr/bin
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["php-fpm"]
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
set -e
echo "Creating the database if it does not exist..."
php bin/console doctrine:database:create --if-not-exists
# Check if migrations need to be applied
if ! php bin/console doctrine:migrations:up-to-date --quiet; then
echo "Applying migrations..."
php bin/console doctrine:migrations:migrate --no-interaction
fi
# Check if FORCE_SCHEMA_UPDATE is set to true
if [ "$FORCE_SCHEMA_UPDATE" = "true" ]; then
echo "Forcing schema update..."
php bin/console doctrine:schema:update --force
fi
# Execute the CMD from the Dockerfile
exec "$@"