Skip to content

Commit 529fd20

Browse files
author
Thanapat
committed
updated: run laravel swoole in supervisor
1 parent 3864d77 commit 529fd20

8 files changed

Lines changed: 72 additions & 57 deletions

File tree

.env.example

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker-compose.yml

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,24 @@
11
version: "3.1"
22
services:
3-
postgres:
4-
image: postgres:alpine
5-
container_name: laravel-postgres
6-
working_dir: /app
7-
volumes:
8-
- ./app:/app
9-
environment:
10-
- POSTGRES_USER=${POSTGRES_USER}
11-
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
12-
- POSTGRES_DB=${POSTGRES_DB}
3+
nginx:
4+
image: nginx:alpine
5+
container_name: my-nginx
6+
working_dir: /app
7+
volumes:
8+
- ./app:/app
9+
- ./docker/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
10+
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
11+
ports:
12+
- "80:80" # HTTP
1313

14-
nginx:
15-
image: nginx:alpine
16-
container_name: laravel-nginx
17-
working_dir: /app
18-
volumes:
19-
- ./app:/app
20-
- ./mydocker/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
21-
- ./mydocker/nginx/conf.d:/etc/nginx/conf.d:ro
22-
ports:
23-
- "80:80" # HTTP
24-
25-
php-fpm:
26-
build: mydocker/php-fpm
27-
container_name: laravel-php-fpm
28-
working_dir: /app
29-
volumes:
30-
# Change directory name to your project name. Example "./app/YOUR_DIRECTORY_NAME:/app"
31-
- ./app/laravel-swoole-tutorial:/app
32-
- ./mydocker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
33-
ports:
34-
- "1215:1215" # Swoole port
35-
# - "9000:9000" # PHP-FPM port
36-
# When the container starts up, it will run Swoole immediately.
37-
command: bash -c "php artisan swoole:http start" # Uncomment this if your use Swoole.
14+
php:
15+
build: docker/php
16+
container_name: my-php
17+
working_dir: /app
18+
volumes:
19+
# Change directory name to your project name. Example "./app/YOUR_DIRECTORY_NAME:/app"
20+
- ./app/laravel-swoole-tutorial:/app
21+
- ./docker/php/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
22+
ports:
23+
- "1215:1215" # Swoole port
24+
# - "9000:9000" # PHP-FPM port

docker/php/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM php:7.4-fpm
2+
WORKDIR "/app"
3+
4+
# Fix debconf warnings upon build
5+
ARG DEBIAN_FRONTEND=noninteractive
6+
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
7+
8+
# Update packages & Install Git and Supervisor
9+
RUN apt-get update -y && \
10+
apt-get install -yq git supervisor
11+
12+
# Install GD extension
13+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
14+
RUN docker-php-ext-install -j "$(nproc)" gd
15+
16+
# Install Swoole extension
17+
RUN pecl install swoole
18+
RUN docker-php-ext-enable swoole
19+
20+
# Install Composer
21+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
22+
23+
# Added supervisor config
24+
COPY supervisord.conf /etc/supervisor/conf.d/supervisor.conf
25+
CMD ["/usr/bin/supervisord", "-n"]

docker/php/supervisord.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# [program:php-fpm]
2+
# command=/usr/local/sbin/php-fpm
3+
# numprocs=1
4+
# autostart=true
5+
# autorestart=true
6+
# priority=100
7+
8+
[program:laravel-worker]
9+
process_name=%(program_name)s_%(process_num)02d
10+
command=php /app/laravel-swoole-tutorial/artisan queue:work --sleep=3 --tries=3 --max-time=3600
11+
autostart=true
12+
autorestart=true
13+
stopasgroup=true
14+
killasgroup=true
15+
numprocs=8
16+
redirect_stderr=true
17+
stopwaitsecs=3600
18+
19+
[program:swoole]
20+
command=php /app/laravel-swoole-tutorial/artisan swoole:http start
21+
redirect_stderr=true
22+
autostart=true
23+
autorestart=true
24+
numprocs=1
25+
process_name=%(program_name)s_%(process_num)s
26+
stdout_logfile=/app/laravel-swoole-tutorial/storage/logs/swoole_http.log

mydocker/php-fpm/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)