Skip to content

Commit ee5172f

Browse files
author
Jovert Lota Palonpon
committed
Created micro-services: queues & jobs, resolve #24
1 parent 67e8d5f commit ee5172f

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

.docker/php/Dockerfile renamed to .docker/php-fpm/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,13 @@ RUN composer install --no-interaction --no-plugins --no-scripts
4646
# Copy app
4747
COPY . ${MASTER_DIR}
4848

49+
# Copy scripts
50+
COPY ./.docker/scripts/queuer.sh /usr/local/bin/laravel-queuer
51+
COPY ./.docker/scripts/scheduler.sh /usr/local/bin/laravel-scheduler
52+
53+
# Give the scripts executable permissions
54+
RUN chmod u+x /usr/local/bin/laravel-queuer
55+
RUN chmod u+x /usr/local/bin/laravel-scheduler
56+
4957
EXPOSE 9000
5058
CMD ["php-fpm"]
File renamed without changes.

.docker/scripts/queuer.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
php /var/www/html/artisan queue:work --verbose --tries=3 --timeout=90

.docker/scripts/scheduler.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
while [ true ]
4+
do
5+
php /var/www/html/artisan schedule:run --verbose --no-interaction &
6+
sleep 60
7+
done

.docker/webserver/nginx.conf.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ server {
1010
location ~ \.php$ {
1111
try_files $uri =404;
1212
fastcgi_split_path_info ^(.+\.php)(/.+)$;
13-
fastcgi_pass laravel-react-admin-php:9000;
13+
fastcgi_pass laravel-react-admin-php-fpm:9000;
1414
fastcgi_index index.php;
1515
include fastcgi_params;
1616
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

docker-compose.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
version: '3'
22
services:
3-
laravel-react-admin-php:
3+
php-fpm:
44
build:
55
context: .
6-
dockerfile: ./.docker/php/Dockerfile
7-
container_name: laravel-react-admin-php
6+
dockerfile: ./.docker/php-fpm/Dockerfile
7+
image: laravel-react-admin-php-fpm
8+
container_name: laravel-react-admin-php-fpm
89
restart: unless-stopped
910
working_dir: /var/www/html
1011
volumes:
1112
- ./:/var/www/html
12-
- ./.docker/php/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
13+
- ./.docker/php-fpm/php.ini:/usr/local/etc/php/conf.d/local.ini:ro
1314
env_file:
1415
- .env
1516

16-
laravel-react-admin-webserver:
17+
scheduler:
18+
image: laravel-react-admin-php-fpm
19+
container_name: laravel-react-admin-scheduler
20+
volumes:
21+
- ./:/var/www/html
22+
depends_on:
23+
- php-fpm
24+
command: laravel-scheduler
25+
env_file:
26+
- .env
27+
28+
queuer:
29+
image: laravel-react-admin-php-fpm
30+
container_name: laravel-react-admin-queuer
31+
volumes:
32+
- ./:/var/www/html
33+
depends_on:
34+
- php-fpm
35+
command: laravel-queuer
36+
env_file:
37+
- .env
38+
39+
webserver:
1740
image: nginx:alpine
1841
container_name: laravel-react-admin-webserver
1942
restart: unless-stopped
@@ -24,9 +47,9 @@ services:
2447
- ./:/var/www/html
2548
- ./.docker/webserver/nginx.conf:/etc/nginx/conf.d/nginx.conf
2649
depends_on:
27-
- laravel-react-admin-php
50+
- php-fpm
2851

29-
laravel-react-admin-db:
52+
db:
3053
image: mysql:5.7
3154
container_name: laravel-react-admin-db
3255
restart: unless-stopped
@@ -38,4 +61,4 @@ services:
3861
volumes:
3962
- ~/.laravel-react-admin-data:/var/lib/mysql
4063
depends_on:
41-
- laravel-react-admin-php
64+
- php-fpm

0 commit comments

Comments
 (0)