Skip to content

Commit

Permalink
Created micro-services: queues & jobs, resolve #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Jovert Lota Palonpon committed Apr 6, 2019
1 parent 67e8d5f commit ee5172f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .docker/php/Dockerfile → .docker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,13 @@ RUN composer install --no-interaction --no-plugins --no-scripts
# Copy app
COPY . ${MASTER_DIR}

# Copy scripts
COPY ./.docker/scripts/queuer.sh /usr/local/bin/laravel-queuer
COPY ./.docker/scripts/scheduler.sh /usr/local/bin/laravel-scheduler

# Give the scripts executable permissions
RUN chmod u+x /usr/local/bin/laravel-queuer
RUN chmod u+x /usr/local/bin/laravel-scheduler

EXPOSE 9000
CMD ["php-fpm"]
File renamed without changes.
3 changes: 3 additions & 0 deletions .docker/scripts/queuer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

php /var/www/html/artisan queue:work --verbose --tries=3 --timeout=90
7 changes: 7 additions & 0 deletions .docker/scripts/scheduler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

while [ true ]
do
php /var/www/html/artisan schedule:run --verbose --no-interaction &
sleep 60
done
2 changes: 1 addition & 1 deletion .docker/webserver/nginx.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ server {
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass laravel-react-admin-php:9000;
fastcgi_pass laravel-react-admin-php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Expand Down
39 changes: 31 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
version: '3'
services:
laravel-react-admin-php:
php-fpm:
build:
context: .
dockerfile: ./.docker/php/Dockerfile
container_name: laravel-react-admin-php
dockerfile: ./.docker/php-fpm/Dockerfile
image: laravel-react-admin-php-fpm
container_name: laravel-react-admin-php-fpm
restart: unless-stopped
working_dir: /var/www/html
volumes:
- ./:/var/www/html
- ./.docker/php/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
- ./.docker/php-fpm/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
env_file:
- .env

laravel-react-admin-webserver:
scheduler:
image: laravel-react-admin-php-fpm
container_name: laravel-react-admin-scheduler
volumes:
- ./:/var/www/html
depends_on:
- php-fpm
command: laravel-scheduler
env_file:
- .env

queuer:
image: laravel-react-admin-php-fpm
container_name: laravel-react-admin-queuer
volumes:
- ./:/var/www/html
depends_on:
- php-fpm
command: laravel-queuer
env_file:
- .env

webserver:
image: nginx:alpine
container_name: laravel-react-admin-webserver
restart: unless-stopped
Expand All @@ -24,9 +47,9 @@ services:
- ./:/var/www/html
- ./.docker/webserver/nginx.conf:/etc/nginx/conf.d/nginx.conf
depends_on:
- laravel-react-admin-php
- php-fpm

laravel-react-admin-db:
db:
image: mysql:5.7
container_name: laravel-react-admin-db
restart: unless-stopped
Expand All @@ -38,4 +61,4 @@ services:
volumes:
- ~/.laravel-react-admin-data:/var/lib/mysql
depends_on:
- laravel-react-admin-php
- php-fpm

0 comments on commit ee5172f

Please sign in to comment.