Skip to content

Instantly share code, notes, and snippets.

@serhiinkh
Created December 30, 2018 15:18
Show Gist options
  • Save serhiinkh/39fdfabe2e2737e75d88dc423b0e2bef to your computer and use it in GitHub Desktop.
Save serhiinkh/39fdfabe2e2737e75d88dc423b0e2bef to your computer and use it in GitHub Desktop.
laravel queue worker docker-compose config
server {
listen 8080;
index index.php index.html;
server_name _;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/app/public;
client_max_body_size 10M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
FROM php:7.2-fpm
WORKDIR /var/www/app
RUN apt-get update -y && apt-get install -y openssl zip unzip git libpng-dev libfreetype6-dev libjpeg62-turbo-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo_mysql gd zip
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
FROM php:7.2-cli
WORKDIR /etc/supervisor/conf.d
RUN apt-get update -y && apt-get install -y supervisor procps
RUN mkdir -p /var/log/supervisor
RUN docker-php-ext-install pdo pdo_mysql pcntl
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["supervisord"]
[supervisord]
nodaemon=true
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work database --queue=high,default --sleep=3 --tries=5
autostart=true
autorestart=true
numprocs=1
startretries=10
stdout_events_enabled=1
stdout_logfile=/var/log/supervisor/laravel-worker.log
[supervisorctl]
version: '3'
services:
nginx:
image: nginx:latest
ports:
- "80:8080"
volumes:
- ./.docker/nginx/nginx.conf:/etc/nginx/conf.d/nginx.conf
- .:/var/www/app
- ../storage:/var/www/app/storage
links:
- php
- db
restart: always
db:
image: mysql:5.7
ports:
- "3306:3306"
volumes:
- db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: password
php:
build:
context: ./.docker/php
dockerfile: Dockerfile
volumes:
- .:/var/www/app
- ../storage:/var/www/app/storage
restart: always
links:
- db
worker:
build:
context: ./.docker/worker
dockerfile: Dockerfile
volumes:
- .:/var/www/app
- ../storage:/var/www/app/storage
restart: always
links:
- db
volumes:
db:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment