Skip to content

Commit

Permalink
Update use supervisor (#17)
Browse files Browse the repository at this point in the history
* use supervisor

* update supervisord.conf
  • Loading branch information
rifkiyupra authored Feb 19, 2025
1 parent ea8f0f3 commit 01f583f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apk add --no-cache \
git \
nodejs \
npm \
supervisor \
xvfb

# Install PHP extensions (INCLUDING POSTGRESQL)
Expand All @@ -25,8 +26,17 @@ RUN docker-php-ext-install pdo pdo_pgsql pgsql opcache gd
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Copy Laravel files
COPY . .
COPY supervisord.conf /etc/supervisord.conf
COPY cronjob.conf /etc/cron.d/cronjob.conf

RUN chmod 0644 /etc/cron.d/cronjob.conf

RUN chmod +x ./startup.sh

# Install dependencies
RUN composer install --no-dev --optimize-autoloader
Expand All @@ -44,6 +54,4 @@ RUN npm instal && npm run build
# Expose port for PHP-FPM
EXPOSE 9000

# Start PHP-FPM
CMD ["/bin/sh", "-c", "php artisan migrate --force && php-fpm"]

ENTRYPOINT [ "/var/www/html/startup.sh" ]
1 change: 1 addition & 0 deletions cronjob.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * www-data php /var/www/html/artisan schedule:run >> /dev/null 2>&1
4 changes: 4 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
php artisan migrate --force
exec /usr/bin/supervisord -c /etc/supervisord.conf

22 changes: 22 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[supervisord]
nodaemon=true

[program:php-fpm]
command=/usr/local/sbin/php-fpm
autostart=true
autorestart=true
user=root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:cron]
command=/usr/sbin/crond -f -l 8
autostart=true
autorestart=true
user=root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

0 comments on commit 01f583f

Please sign in to comment.