Skip to content

Commit 86319c6

Browse files
committed
add migrascript scrip when servise start up
1 parent a12807d commit 86319c6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cac
3535
# Install PHP dependencies
3636
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
3737

38+
# Copy the entrypoint script
39+
COPY docker-entrypoint.sh /usr/local/bin/
40+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
41+
3842
# Expose port 80
3943
EXPOSE 80
4044

41-
# Start Apache
42-
CMD ["apache2-foreground"]
45+
# Set entrypoint
46+
ENTRYPOINT ["docker-entrypoint.sh"]

docker-entrypoint.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Wait for the database to be ready before running migrations
5+
echo "Waiting for database connection..."
6+
until php artisan migrate --force; do
7+
echo "Migration failed, retrying in 5 seconds..."
8+
sleep 5
9+
done
10+
11+
# Start Apache
12+
exec apache2-foreground

0 commit comments

Comments
 (0)