From b01494542619528333ad801abf49edd45bbc005e Mon Sep 17 00:00:00 2001 From: Loki <59907407+Loki-101@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:50:28 -0800 Subject: [PATCH] Add seeder, move listener to supervisord - No longer overrides base image's CMD - Seeder checks for "OK" anywhere in the output of "php artisan db:monitor", retrying every 5 seconds, then runs the seeder once OK is seen --- Dockerfile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ce7039..6004938 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,5 +61,19 @@ RUN mkdir -p /blueprint_extensions /app COPY .helpers/listen.sh /listen.sh RUN chmod +x /listen.sh -# Set CMD to run the listen script in the background and start supervisord -CMD /listen.sh & exec supervisord -n -c /etc/supervisord.conf \ No newline at end of file +# Append listener and seeder to supervisord +RUN echo "" >> /etc/supervisord.conf && \ + cat >> /etc/supervisord.conf <<'EOF' +[program:database-seeder] +command=/bin/bash -c 'while ! [[ $(/usr/local/bin/php /app/artisan db:monitor) =~ OK ]]; do /bin/sleep 5; done && /usr/local/bin/php /app/artisan db:seed --class=BlueprintSeeder --force' +user=nginx +autostart=true +autorestart=false +startsecs=0 + +[program:listener] +command=/listen.sh +user=root +autostart=true +autorestart=true +EOF