mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 17:09:39 +01:00
13
Dockerfile
13
Dockerfile
@@ -57,19 +57,19 @@ RUN docker-php-ext-install pdo_pgsql
|
|||||||
# Get latest Composer
|
# Get latest Composer
|
||||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
# Copy php.ini file
|
# Copy php.ini file
|
||||||
COPY php/php.ini $PHP_INI_DIR/conf.d/
|
COPY php.ini $PHP_INI_DIR/conf.d/
|
||||||
|
|
||||||
# Install Laravel Envoy
|
# Install Laravel Envoy
|
||||||
RUN composer global require "laravel/envoy=~1.0"
|
RUN composer global require "laravel/envoy=~1.0"
|
||||||
|
|
||||||
#--------------------Add supervisor file in supervisor directory ------------------------------------
|
#--------------------Add supervisor file in supervisor directory ------------------------------------
|
||||||
ADD worker/supervisord.conf /etc/supervisor/conf.d/worker.conf
|
#ADD worker/supervisord.conf /etc/supervisor/conf.d/worker.conf
|
||||||
|
|
||||||
# Add crontab file in the cron directory
|
COPY ./entrypoint.sh /usr/local/bin/
|
||||||
ADD worker/crontab /etc/cron.d/crontab
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
RUN ln -s /usr/local/bin/entrypoint.sh /
|
||||||
|
|
||||||
# Give execution rights on the cron job
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
RUN chmod 0644 /etc/cron.d/crontab
|
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR $WORKDIR
|
WORKDIR $WORKDIR
|
||||||
@@ -77,6 +77,7 @@ WORKDIR $WORKDIR
|
|||||||
RUN usermod -u 1000 www-data
|
RUN usermod -u 1000 www-data
|
||||||
RUN groupmod -g 1000 www-data
|
RUN groupmod -g 1000 www-data
|
||||||
|
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
# Run Supervisor
|
# Run Supervisor
|
||||||
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
#Project root
|
#Project root
|
||||||
- ./:/var/www/
|
- ./:/var/www/
|
||||||
|
- ~/.ssh:/root/.ssh # If you use private CVS
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- default #if you're using networks between containers
|
- default #if you're using networks between containers
|
||||||
|
|
||||||
@@ -51,6 +53,7 @@ php atisan migrate
|
|||||||
|
|
||||||
```
|
```
|
||||||
## Example Laravel-php-fpm with nginx:
|
## Example Laravel-php-fpm with nginx:
|
||||||
|
### file= docker-compose.yml
|
||||||
```yml
|
```yml
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
@@ -61,6 +64,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
#Project root
|
#Project root
|
||||||
- ./:/var/www/
|
- ./:/var/www/
|
||||||
|
- ~/.ssh:/root/.ssh # If you use private CVS
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- default #if you're using networks between containers
|
- default #if you're using networks between containers
|
||||||
#Nginx server
|
#Nginx server
|
||||||
@@ -79,6 +84,7 @@ services:
|
|||||||
|
|
||||||
```
|
```
|
||||||
## Simple Nginx config file content
|
## Simple Nginx config file content
|
||||||
|
### file= nginx/conf.d/default.conf
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
|
|
||||||
|
|||||||
9
build.sh
Normal file
9
build.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
tag='latest'
|
||||||
|
else
|
||||||
|
tag=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker build -t jkaninda/laravel-php-fpm:$tag .
|
||||||
49
entrypoint.sh
Normal file
49
entrypoint.sh
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo ""
|
||||||
|
echo "***********************************************************"
|
||||||
|
echo " Starting LARAVEL PHP-FPM Docker Container "
|
||||||
|
echo "***********************************************************"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TASK=/etc/supervisor/conf.d/worker.conf
|
||||||
|
touch $TASK
|
||||||
|
cat > "$TASK" <<EOF
|
||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
user=root
|
||||||
|
|
||||||
|
[program:php-fpm]
|
||||||
|
command=/usr/local/sbin/php-fpm
|
||||||
|
numprocs=1
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stderr_logfile=/var/log/php-fpm_consumer.err.log
|
||||||
|
stdout_logfile=/var/log/php-fpm_consumer.out.log
|
||||||
|
user=root
|
||||||
|
priority=100
|
||||||
|
|
||||||
|
[program:Laravel-scheduler]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=/bin/sh -c "while [ true ]; do (php /var/www/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
numprocs=1
|
||||||
|
user=root
|
||||||
|
stdout_logfile=/var/log/laravel_scheduler.out.log
|
||||||
|
redirect_stderr=true
|
||||||
|
|
||||||
|
[program:Laravel-worker]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=php /var/www/artisan queue:work --sleep=3 --tries=3
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
numprocs=2
|
||||||
|
user=root
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile=/var/log/laravel_worker.log
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
supervisord -c /etc/supervisor/supervisord.conf
|
||||||
|
|
||||||
Reference in New Issue
Block a user